Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Combobox - Items Centered (https://www.delphipraxis.net/95643-combobox-items-centered.html)

mischerr 10. Jul 2007 21:28


Combobox - Items Centered
 
Weiss zufällig jemand wie ich bei einer TComboBox (genauergesagt geht es um die Unicode - TTNTComboBox) die Auswahl + Items zentriere?

Wie beim TEdit CreateParams zu überschreiben und ES_CENTER zu setzen funktioniert leider nicht.
Bei ES_Center ist die Box nicht mehr beschreibbar und bei ES_Right entsprechen Darstellung und Verhalten ES_Left.

Hat jemand eine Idee?

[erledigt]

Solve:

Code:
procedure TForm1.TntComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
var w,
    l  : integer;
    text: widestring;
begin
  text:= TntComboBox1.Items.Strings[Index];
  w:= TntComboBox1.Canvas.TextWidth(text);
  l:= (Rect.Right - Rect.Left - w) div 2;
  TntComboBox1.Canvas.TextOut(Rect.Left + l, Rect.Top, text);
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:14 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz