delphi 磁性窗体

delphi 磁性窗体

ID:44890241

大小:28.00 KB

页数:3页

时间:2019-11-01

delphi 磁性窗体_第1页
delphi 磁性窗体_第2页
delphi 磁性窗体_第3页
资源描述:

《delphi 磁性窗体》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、转载自百度空间,技术文档,以便自学Delphi磁性窗体FORM1unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;typeTForm1=class(TForm)   Button1:TButton;   Button2:TButton;   procedureButton1Click(Sender:TObject);   procedureButt

2、on2Click(Sender:TObject);private   {Privatedeclarations}public   {Publicdeclarations}end;varForm1:TForm1;implementationusesunit2;{$R*.dfm}procedureTForm1.Button1Click(Sender:TObject);beginform2.Show;end;procedureTForm1.Button2Click(Sender:TObject);beginclos

3、e;end;end.下边是测试用的form2unitUnit2;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs;typeTForm2=class(TForm)privateprocedureWMWINDOWPOSCHANGING(VarMsg:TWMWINDOWPOSCHANGING);messageWM_WINDOWPOSCHANGING;   {Privatedeclaratio

4、ns}public   {Publicdeclarations}end;varForm2:TForm2;implementationusesUnit1;{$R*.dfm}{TForm2}procedureTForm2.WMWINDOWPOSCHANGING(varMsg:TWMWINDOWPOSCHANGING);varWorkDound:TRect;remove:Word;beginremove:=50;//可随意设置,是磁性的范围大小。WorkDound.Left:=form1.left;WorkDoun

5、d.Top:=form1.Top;WorkDound.Right:=form1.left+form1.Width;WorkDound.Bottom:=form1.Top+form1.Height;withMsg.WindowPos^dobegin   if(x+cxWorkDound.Left-remove)or((x+cx>WorkDound.Left)and(x+cx

6、ove))then       begin         x:=WorkDound.Left-cx;       end;   if(x>WorkDound.Right-remove)then  //右方具有磁性     if(xWorkDound.Right-remove))then       begin         x:=WorkDound.Right;       end;   if(y+cy

7、WorkDound.Top-remove)or((y+cy>WorkDound.Top)and(y+cyWorkDound.Bottom-remove)then  //下方具有磁性     if(y

8、ove)or((yWorkDound.Bottom-remove))then       begin         y:=WorkDound.Bottom;       end;end;inherited;end;end.

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。