Delphi-PRAXiS
Seite 2 von 2     12   

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 Listbox Items unselektierbar machen ohne Enabled property (https://www.delphipraxis.net/106820-listbox-items-unselektierbar-machen-ohne-enabled-property.html)

API 17. Jan 2008 11:00

Re: Listbox Items unselektierbar machen ohne Enabled propert
 
{Listbox1.Style := lbOwnerDrawFixed}

Delphi-Quellcode:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with TListbox(Control) do
  begin
    if odSelected in State then
    begin
      Canvas.Brush.Color := Color;
      Canvas.Font.Color := Font.Color;
    end;

    Canvas.FillRect(Rect);

    Rect.Left := Rect.Left + 2;

    DrawText(Canvas.Handle,
      PChar(Items[Index]),
      -1,
      Rect,
      DT_SINGLELINE or DT_VCENTER);
  end;
end;
Falls du den Focus Rahmen noch wegbringen möchtest, wird's wohl komplizierter...

richard_boderich 17. Jan 2008 11:01

Re: Listbox Items unselektierbar machen ohne Enabled propert
 
@API

genau darum geht es.

mfg Richard

API 17. Jan 2008 11:06

Re: Listbox Items unselektierbar machen ohne Enabled propert
 
oder so?

Delphi-Quellcode:
with (Control as TListBox) do
  begin
    Canvas.Brush.Color := Color;
    Canvas.Font.Color := Font.Color;
    canvas.FillRect(rect);
    DrawText(Canvas.Handle,
      PChar(Items[Index]),
      -1,
      Rect,
      DT_SINGLELINE or DT_VCENTER);
    if odSelected in state then
      Canvas.DrawFocusRect(rect);
  end;

richard_boderich 17. Jan 2008 11:18

Re: Listbox Items unselektierbar machen ohne Enabled propert
 
@API

Also das scheint meistens zu funktionieren, jedoch hatte ich beim Test hier 1 mal eine Doppelzeichnung des item selectframes.
Trotzdem vielen Dank für deine Hilfe.

mfG Richard


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:28 Uhr.
Seite 2 von 2     12   

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 by Thomas Breitkreuz