欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Delphi實(shí)現(xiàn)窗體感知鼠標(biāo)滑過(guò)并自動(dòng)隱藏與顯示窗口的方法

 更新時(shí)間:2015年05月08日 15:38:47   作者:xujh  
這篇文章主要介紹了Delphi實(shí)現(xiàn)窗體感知鼠標(biāo)滑過(guò)并自動(dòng)隱藏與顯示窗口的方法,涉及Delphi操作窗口及鼠標(biāo)事件的技巧,需要的朋友可以參考下

本文實(shí)例講述了Delphi實(shí)現(xiàn)窗體感知鼠標(biāo)滑過(guò)并自動(dòng)隱藏與顯示窗口的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

const
 WM_MouseEnter = $B013;
 WM_MouseLeave = $B014;
type
 TfrmMain = class(TForm)
  .
  .
 Timer1: TTimer;
 procedure Timer1Timer(Sender: TObject);
 protected
 procedure WMMouseEnter(var Msg: TMessage); message WM_MouseEnter;
 end;
implementation
{$R *.dfm}
procedure TfrmMain.WMMouseEnter(var Msg: TMessage);
begin
 if(Top<0) then
 begin
 Top := 0;
 //為保證下拉窗體后呈現(xiàn)在最前面
 SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
 //將窗體推到最前
 SetWindowPos(Handle,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
 //然后取消窗體最前
 end;
 Timer1.Enabled := True;
end;
//依賴定時(shí)器定時(shí)檢查鼠標(biāo)是否還在窗體范圍內(nèi),
//這樣此能避免因?yàn)榭焖僖苿?dòng)鼠標(biāo)而丟失MOUSELEAVE事件
procedure TfrmMain.Timer1Timer(Sender: TObject);
var
 rc:TRECT;
 pt:TPOINT;
begin
 GetWindowRect(self.Handle,rc); //取窗體的矩形區(qū)域
 GetCursorPos(pt); //取得當(dāng)前鼠標(biāo)所在位置
 if(not PtInRect(rc,pt)) then //如果鼠標(biāo)不在窗體范圍內(nèi)
 begin
  if(Top = 0) then
  //如果目前窗體正吸附在屏幕上沿,則上移隱藏窗體
  begin
   Top := 0-Height+2;
  end;
  Timer1.Enabled := False; //窗體隱藏后定時(shí)器關(guān)閉
  SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
  //將窗體推到最前
 end;
end;

希望本文所述對(duì)大家的Delphi程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論