您现在的位置:首页 >> VCL >> VCL >> 内容

Delphi中给活动控件画上矩形边框

时间:2011/9/3 16:23:46 点击:

  核心提示: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;


 

作者:站长 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号