![]() |
Focusrechteck bei selbstgezeichneter Listbox
Liste der Anhänge anzeigen (Anzahl: 1)
Ich zeichne mit folgende,m Code die Inahlte einer Listbox selber:
Delphi-Quellcode:
Funktioniert soweit auch ganz gut. Es gibt nur einen Schönheitsfehler, wenn ich nacheinander Items anklicke mit der Maus, bleibt der gepunktete Rahmen bei allen Items erhalten. Wie kann ich dafür sorgen, dass der gepunktete Rahmen entfernt wird bei den vorherigen Items?
procedure DrawItems(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
const Col2 : array[Boolean] of TColor = (clInactiveCaptionText, clWindowText); var Bmp: TBitmap; ItemCaption : string; Nachname : string; Vorname : string; Firma : string; Tele1 : string; Tele2 : string; begin Nachname := TContact((Control as TListbox).Items.Objects[Index]).Name; Vorname := TContact((Control as TListbox).Items.Objects[Index]).Vorname; Firma := TContact((Control as TListbox).Items.Objects[Index]).Firma; Tele1 := RemoveNonNumberChrs(TContact((Control as TListbox).Items.Objects[Index]).Telefon1); Tele2 := RemoveNonNumberChrs(TContact((Control as TListbox).Items.Objects[Index]).Telefon2); ItemCaption := Helper.Makecaption(Nachname, Vorname, Firma); with (Control as TListbox) do begin if odSelected in State then Canvas.Font.Color := clCaptionText else Canvas.Font.Color := Col2[(Control as TListbox).Enabled]; // Grafik Bmp := TBitmap.Create; try Main.frmAdressen.ImageList1.GetBitmap(6, Bmp); Canvas.Draw(Rect.Left + 4, Rect.Top + 4, Bmp); finally Bmp.Free; end; // Itemcaption Canvas.Font.Style := [fsBold]; Canvas.Font.Size := 12; Canvas.Font.Name := 'Arial'; Canvas.TextOut(Rect.Left + 25, Rect.Top + 3, ItemCaption); // SubText Canvas.Font.Style := []; Canvas.Font.Size := 10; Rect.Left := Rect.Left + 10; Rect.Top := rect.Top + 2 + 19; // nur Telefon1 if Tele1 <> '' then begin DrawText(Canvas.Handle, PChar(Tele1), length(Tele1), Rect, DT_LEFT); end; // nur Telefon2 if Tele2 <> '' then begin DrawText(Canvas.Handle, PChar(Tele2), length(Tele2), Rect, DT_LEFT); end; // beides if (Tele1 <> '') and (Tele2 <> '') then begin DrawText(Canvas.Handle, PChar(Tele1), length(Tele1), Rect, DT_LEFT); Rect.Left := Rect.Left + 125; DrawText(Canvas.Handle, PChar(Tele2), length(Tele2), Rect, DT_LEFT); end; end; end; Im Anhang ein Screenshot. Ich hoffe, man kann erkennen, was ich meine. |
Re: Focusrechteck bei selbstgezeichneter Listbox
Hallo Luckie,
ich denke, du müsstest das gesamte Rect erstmal mit der Hintergrundfarbe ausmalen (mit FillRect), wenn nicht Selected, bevor du da was 'reinschreibst. Gruss Geronimo |
Re: Focusrechteck bei selbstgezeichneter Listbox
Das war die Lösung. Damit hat sich auch gleich noch ein anderes Problem gelöst. Vorher war nämlich imme rnur der Text farbig hinterlegt, wenn man ein Item selektiert hat, jetzt ist das ganze Rechteckt farbig hinterlegt. Besten Dank.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:45 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz