Jump to content


Photo

Focus indicator


  • Please log in to reply
No replies to this topic

#1 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 23 October 2006 - 05:42 PM

Hi All,

Bit off-topic but here some code for a focus indicator for the active control on a form. For the code to work add a timer (approx 250 msec interval) to the form and add the following code to the OnTimer event. Also add

CODE
fLastActiveControl : TWinControl;

to the private section of the Form.

CODE
procedure TForm1.Timer1Timer(Sender: TObject);
var
  b                             : TRect;
begin
  if Assigned(fLastActiveControl) and (fLastActiveControl <> ActiveControl) then
    begin
      b := fLastActiveControl.BoundsRect;
      Dec(b.Left);
      Dec(b.Top);
      Inc(b.Right);
      Inc(b.Bottom);
      Canvas.Brush.Color := Color;
      Canvas.FrameRect(b);
    end;

  if Assigned(ActiveControl) then
    begin
      b := ActiveControl.BoundsRect;
      Dec(b.Left, 1);
      Dec(b.Top, 1);
      Inc(b.Right, 1);
      Inc(b.Bottom, 1);
      Canvas.Brush.Color := cLRed;
      Canvas.FrameRect(b);
    end;

  fLastActiveControl := ActiveControl;
end;

G.W. van der Vegt




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users