procedure TForm1.FormCreate(Sender: TObject);
begin
Combobox1.Style := csOwnerDrawVariable;
// fill the combobox with some examples
with Combobox1.Items do
begin
Add('Short, kurzer String');
Add('A long String. / Ein langer String.....');
Add('Another String');
Add('abcd defg hijk lmno');
Add('..-.-.-.-.-.-.-.-.-');
end;
end;
procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
var
i, PosSp: Integer;
strVal: string;
strTmp: string;
begin
if Index >= 0 then
begin
strVal := Combobox1.Items[Index];
// wrap string to multiple lines, each line separated by #$D#$A
strTmp := WrapText(strVal, 20);
// Number of line separators + 1 = number of lines
i := 1;
while Pos(#$D#$A, strTmp) > 0 do
begin
i := i + 1;
strTmp := Copy(strTmp, Pos(#13#10, strTmp) + 2, Length(strTmp));
end;
// calcualte the height for the text
Height := i * Combobox1.ItemHeight;
end;
end;
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
strVal: string;
strTmp: string;
intPos: Integer;
i: Integer;
rc: TRect;
begin
// wrap the text
strVal := WrapText(Combobox1.Items[Index], 20);
i := 0;
Combobox1.Canvas.FillRect(Rect);
// output each single line
while Pos(#$D#$A, strVal) > 0 do
begin
intPos := Pos(#$D#$A, strVal);
// copy current line from string
if intPos > 0 then
strTmp := Copy(strVal, 1, intPos - 1)
else
strTmp := strVal;
rc := Rect;
rc.Top := Rect.Top + i * Combobox1.ItemHeight;
ComboBox1.Canvas.TextRect(rc, Rect.Left, Rect.Top + i * Combobox1.ItemHeight,
strTmp);
// delete the written line from the string
strVal := Copy(strVal, intPos + 2, Length(strVal));
Inc(i);
end;
rc := Rect;
rc.Top := Rect.Top + i * Combobox1.ItemHeight;
// write the last line
ComboBox1.Canvas.TextRect(rc, Rect.Left, Rect.Top + i * Combobox1.ItemHeight, strVal);
Combobox1.Canvas.Brush.Style := bsClear;
// surround the text with a rectangle
Combobox1.Canvas.Rectangle(Rect);
end;

Multiline ComboBox
Abonnieren
Posts (Atom)
Beliebte Posts
-
Windows Key Sniffer 0.82 - Update 08/2024 Der Windows Key Sniffer hat mir im Laufe der Zeit viel Arbeit erspart und unterstützt, viele Wi...
-
Network Source Code Update Source Code Network Update : https://asciigen.blogspot.com/p/network.html Send Message 1.0 Source Server Client ...
-
Windows Defender Bypass Version 0.75 - Update 11/2024 Den Windows 10-eigenen Virenschutz Defender kann man auf mehreren Wegen abschalt...
-
ASCii GIF Animator Update Version 0.68 (32 bit) - 11/2024 Bei dieser überarbeiteten Version ist die Kompatibilität zu den verschiedenen...
-
MD5 Hacker v.0.26 - Update 08.2024 MD5 Hashs sollten eigentlich nicht entschlüsselt werden können. Jedoch gibt es Tools, mit welchen auch ...
-
Dir Sniffer Version 0.11 - Update 02/2025 Dir Sniffer ist ein kleines aber nützliches Tool um herauszufinden, was ihr Programm auf ihrem...
-
Host Editor Version 0.65 - Update 01/2025 Hosts File Editor allows for the easy editing of host files and backup creation. Create your ...
-
Oldskool Font Generator v.0.29 - Update 11/2023 Das Tool stell 508 Bitmap Fonts zu Verfügung. Eigene Fonts können integriert werden, sie...
-
Hard Crypter 0.19 - Update 12/2023 Mit diesem Tool können Sie jede beliebige Datei auf dem Windows-System verschlüsseln. Die Byte-Erse...
Keine Kommentare:
Kommentar veröffentlichen