核心提示:600) this.width = 600;'>窗体创建事件中加如下代码: focusRectangle := TShape.Create(self) ; focusRectangle.Shape :...
600) this.width = 600;">
窗体创建事件中加如下代码:
focusRectangle := TShape.Create(self) ;
focusRectangle.Shape := stRectangle;
focusRectangle.Visible := false;
focusRectangle.Brush.Style := bsClear;
focusRectangle.Pen.Style := psDot;
focusRectangle.Pen.Color := clRed;
focusRectangle.Pen.Width := 1;
在Screen的OnActiveControlChange事件中处理:
with focusRectangle do
begin
Parent := Screen.ActiveControl.Parent;
Top := Screen.ActiveControl.Top - 2;
Height := Screen.ActiveControl.Height + 4;
Left := Screen.ActiveControl.Left - 2;
Width := Screen.ActiveControl.Width + 4;
Visible := true;
end;