title image


Smiley Re: focusrahmen in listbox abstellen
Hi,



Diese von TListbox abgeleitete Komponente zeichnet

keinen Fokusrahmen:



unit NoFocusListBox;



interface



uses

  Windows, Messages, SysUtils, Classes, Controls, StdCtrls;



type

  TNoFocusListBox = class(TListBox)

  private

    { Private declarations }

    procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;

  end;



procedure Register;



implementation



procedure TNoFocusListBox.CNDrawItem(var Message: TWMDrawItem);

var

  State: TOwnerDrawState;

begin

  with Message.DrawItemStruct^ do

  begin

    State := TOwnerDrawState(LongRec(itemState).Lo);

    Canvas.Handle := hDC;

    Canvas.Font := Font;

    Canvas.Brush := Brush;

    if (Integer(itemID) >= 0) and (odSelected in State) then

    begin

      Canvas.Brush.Color := clHighlight;

      Canvas.Font.Color  := clHighlightText

    end;

    if Integer(itemID) >= 0 then

      DrawItem(itemID, rcItem, State)

    else

      Canvas.FillRect(rcItem);

    Canvas.Handle := 0;

  end;

end;



procedure Register;

begin

  RegisterComponents('Samples', [TNoFocusListBox]);

end;



end.





geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: