Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 19.03.07 20:44 
Kann man irgendwie die Items in einer Listbox mittig plazieren? Also horizontal mittig?
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 19.03.07 20:45 
Die wirst du dann wohl selber zeichnen müssen. Stichwort Suche in: Delphi-Forum, Delphi-Library OWNERDRAW

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mo 19.03.07 20:46 
Ich schätz das ist schwieriger, ich glaube dazu müsstest du eine neue Klasse ableiten und darin eine Procedure OwnerDraw überschreiben...
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Mo 19.03.07 20:50 
Schade :schmoll: :gruebel: Egal, dann lass ichs eben
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 19.03.07 21:23 
Ableiten wird man da nix müssen, nur die das Ereignis onDraeItem behandeln und die Eigenschaft Style setzen. :wink:

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Bondfreak
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 21

Win XP Prof, Kubuntu Dapper Drake
Delphi 6 (besitze auch 2005 und 2006)
BeitragVerfasst: Mo 19.03.07 21:41 
user profile iconjakobwenzel hat folgendes geschrieben:
Ableiten wird man da nix müssen, nur die das Ereignis onDraeItem behandeln und die Eigenschaft Style setzen. :wink:


genau so sollte es funzen, hab das selbe problem grad mit nem stringgrid ;)
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 20.03.07 00:39 
Ein Workaround wäre folgendes:

ausblenden 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:
procedure TForm1.Button1Click(Sender: TObject);
var
a,b : string;
begin
a:='hathorhathor';
b:= ' ';
while length(a)<30 do // Stringlänge 30 zum Testen
begin
a:= a + b; //fügt Leerzeichen an
a:= b + a;
end;
Listbox1.Items.Add(IntToStr(length(a))); //zum Testen
Listbox1.Items.Add(a);
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var i:integer; s,t :string;
begin
i:= Listbox1.ItemIndex;
s:= Listbox1.Items.Strings[i];
if Leftstr(s,1)=' ' then
t:= StringReplace(s,' ','',[rfReplaceAll, rfIgnoreCase]);//entfernt Leerzeichen
Showmessage('X'+ t +'X'); //zum Testen
end;
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 20.03.07 00:48 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  DrawText(TListBox(Control).Canvas.Handle, PChar(ListBox1.Items[Index]), length(ListBox1.Items[Index]), Rect,
    DT_CENTER or DT_SINGLELINE);
end;

Style muss auf lbOwnerDrawFixed stehen.