Autor Beitrag
ultra2k
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: So 07.09.03 02:50 
Hi, ich nochmal :wink:

Heute gehts um folgendes...
Ich möchte ein paar dynamisch erzeugte TImage Komponenten auf meiner Form unterbringen, ich brauche einen bestimmten bereich der Komponente als EventHandler (OnMouseEnter + OnMouseLeave), d.h. das TImage ist z.b. 25x25 Pixel groß, die Grafik aber nur 16x16 also hab ich Center auf True gesetzt. Das hat auch geklappt, allerdings hab ich dann zwischendrin ein paar Sachen im Quellcode geändert und auch ein paar mal gespeichert, dann is mir das mit den Images aufgefallen... Die sitzen jetzt nämlich press Linksoben in der Ecke und nich mehr in der Mitte!
(Blöd, ich weiß, aber ich hab mittlerweile eine panische Angst vor Stromausfällen entwickelt :wink: )

Also, wer weiß was???

Zur verdeutlichung der Code:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
procedure TMainForm.ReadSettings;
var
  SettingsFile: TIniFile;
  Shortcut: TExtImage;
  i, count, pos, leftmargin, imageleft: Integer;
  Name, Path, Exe, Icon, AppPath: String;
begin
  AppPath := ExtractFilePath(Application.ExeName);
  if FileExists(AppPath+'settings.ini') then begin
    SettingsFile := TIniFile.Create(AppPath + 'settings.ini');
    count := SettingsFile.ReadInteger('shortcuts', 'count', 0);
    Dec(count);
    for i := 0 to count do begin
      leftmargin := 160;
      pos := i * 25;
      imageleft := leftmargin + pos;

      Name := SettingsFile.ReadString(IntToStr(i), 'name', '');
      Path := SettingsFile.ReadString(IntToStr(i), 'path', '');
      Exe := SettingsFile.ReadString(IntToStr(i), 'path', '');
      Icon := SettingsFile.ReadString(IntToStr(i), 'icon', '');

      Shortcut := TExtImage.Create(self);
      Shortcut.Name := 'ExtIconImage' + IntToStr(i);
      Shortcut.Tag := i;
      Shortcut.OnClick := ShortcutClick;
      Shortcut.Parent := MainForm;
      Shortcut.ShowHint := True;
      Shortcut.Hint := Name;
      Shortcut.Autosize := False;
      Shortcut.Transparent := True;
      Shortcut.Stretch := True;
      Shortcut.Center := True;
      Shortcut.Left := imageleft;
      Shortcut.Width := 25;
      Shortcut.Top := 1;
      Shortcut.Height := 23;
      Shortcut.Picture.LoadFromFile(Icon);
      Shortcut.Update;
    end;
    SettingsFile.Free;
  end else begin
    ShowMessage('Config file does not exist! New file has been created...');
    CreateDefaultIni;
  end;
end;


Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 07.09.03 04:17 
Top steht auf 1 und Left ist nicht gesetzt, wo soll das TImage also hin als, oben links in die Ecke?
ultra2k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: So 07.09.03 17:30 
Top is 1, weil es ja ein Pixel von oben entfernt sein soll, und Left is auch gesetzt!

ja, das soll so aussehen (wegen center):

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
+--------+
| TImage |
| +----+ |
| |bild| |
| +----+ |
|        |
+--------+



// edit: Also, die Image-Komponente soll 25x25 groß sein und das eigentliche Bild nur 16x16. Klar sitzt das Bild IN der Komponente linksoben, aber sollte es doch nicht mehr, wenn ich center aktiviere...
Dann müsste es doch 4 pixel von links und oben und 5 Pixel (oder so ähnlich) von der jeweils gegenüberliegenden Seite sitzen, oder???
(Wenns immer noch net klar is, sagt bescheid)

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
ultra2k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: Mi 10.09.03 21:55 
Och kommt schon Leute, weiß keiner was???

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!