在delphi中如何实现象QQ表单那样,鼠标离开QQ表单后的自动缩入(100分)

  • 主题发起人 主题发起人 suhang999
  • 开始时间 开始时间
S

suhang999

Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi中如何实现象QQ表单那样,鼠标离开QQ表单后的自动缩入,同时鼠标放在QQ表单的<br>边界后的自动弹出。<br>最好是有一段源代码。<br>suhang999@hotmail.com
 
简单:<br>SetCapture(hwnd);<br>如鼠标离开,缩入窗口,<br>再ReleaseCapture();
 
procedure TForm1.Timer2Timer(Sender: TObject);<br>var<br>cur:tpoint;rct:trect;<br>begin &nbsp; &nbsp; &nbsp; &nbsp;<br>if form1.top&lt;5 then<br>begin<br>GetCursorPos(cur);//得到鼠标的当前位置<br>GetWindowRect(Handle,rct);//得到窗口的区域<br>if not PtInRect(rct,cur) then//判断鼠标是否在窗口里<br>begin<br>form1.height:=3;<br>form1.Top:=0;<br>end<br>else<br>form1.height:=400;<br>end;<br>end;
 
http://www.cnkmai.com/bbs/<br>有我收集的很多的资料。有你需要的。!找一下。我就用了这个的。!
 
procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>&nbsp; Cursor: TPoint ;<br>&nbsp; WDZzone: TRect ;<br>begin<br>&nbsp; &nbsp;GetCursorPos(Cursor) ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //获得鼠标的当前位置<br>&nbsp; &nbsp;GetWindowRect(Handle,WDZzone) ; &nbsp; &nbsp; &nbsp;//获得窗口的区域<br>&nbsp; &nbsp;if self.Top &lt;3 then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;if not PtInRect(WDZzone,Cursor) then &nbsp; //判断鼠标是否在窗口里<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.Top := 0-self.Height+1 &nbsp; &nbsp; &nbsp; &nbsp; //窗体在屏幕上方<br>&nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.Top := 0 ;<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else if self.Left &gt; screen.Width-self.Width-5 then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; if not PtInRect(WDZzone,Cursor) then &nbsp; &nbsp; //窗体在屏幕右方<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.Left := screen.Width -1<br>&nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.Left := screen.Width-self.Width<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else if self.Left &lt;3 then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; if not PtInRect(WDZzone,Cursor) then &nbsp; &nbsp; &nbsp;//窗体在屏幕左方<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.Left := 0-self.Width +1 <br>&nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.Left := 0 ;<br>&nbsp; &nbsp;end <br>end;<br>再把窗体的FormStyle属性设为fsStayOnTop效果会更好
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
892
DelphiTeacher的专栏
D
D
回复
0
查看
956
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部