Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove FocusRect

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi all.

Is there a way to remove the Focus rectange from an ordinary TListBox without creating a new Component.

I've tried to override the OnDrawItem, but the FocusREct is drawn after the OnDrawItem is fired...



//Nordlund
 
Hi Norlund
I cant belive I'm posting this dirtier than a dust bin lid code but..

try
listbox.selected[0]:= false;
except
end;

arrrgggg
rectangle gone (if this is what you meant)





Steve
Two things are infinite
The Universe and Human stupidity: Einstein.
(He wasn't too sure about the Universe)
 
LOL....
Yep. It was dirty indeed... :)

But this is not what I really want to do, but I've fixed it anyway.
I created an descendant to TCheckListBox, and rewriote the OnDraItem and CNDrawItem procedures...

One of the things I tagged was this:
Code:
procedure TCustomListBox.CNDrawItem(var Message: TWMDrawItem);
var
  State: TOwnerDrawState;
begin
  with Message.DrawItemStruct^ do
  begin
    State := TOwnerDrawState(LongRec(itemState).Lo);
    FCanvas.Handle := hDC;
    FCanvas.Font := Font;
    FCanvas.Brush := Brush;
    if (Integer(itemID) >= 0) and (odSelected in State) then
    begin
      FCanvas.Brush.Color := clHighlight;
      FCanvas.Font.Color := clHighlightText
    end;
    if Integer(itemID) >= 0 then
      DrawItem(itemID, rcItem, State) else
      FCanvas.FillRect(rcItem);
//    if odFocused in State then DrawFocusRect(hDC, rcItem); This row was tagged
    FCanvas.Handle := 0;
  end;
end;



//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top