各位网友大家好!
我想实现类似QQ的窗体隐藏功能(鼠标放上去显示,挪开就隐藏),基本功能是实现了,可是现在只能识别窗体,而窗体上的控件就不行了。鼠标放到控件上,窗体就隐藏了。如何才能让窗体上的所有控件也能识别鼠标,等鼠标彻底离开窗口后再隐藏。先谢谢了.由于我积分已经只有14分了,所以没有办法给大侠们分了,还请多多包涵!谢谢!
我想实现类似QQ的窗体隐藏功能(鼠标放上去显示,挪开就隐藏),基本功能是实现了,可是现在只能识别窗体,而窗体上的控件就不行了。鼠标放到控件上,窗体就隐藏了。如何才能让窗体上的所有控件也能识别鼠标,等鼠标彻底离开窗口后再隐藏。先谢谢了.由于我积分已经只有14分了,所以没有办法给大侠们分了,还请多多包涵!谢谢!
const
cOffset = 4;
begin
pgc_handle
if WindowFromPoint(Mouse.CursorPos)= Handle then //只能识别窗体,而窗体上的控件就不行了。
begin
Top := 0;
Left := 0;
Self.SetFocus;
end
else
begin
Top := -height + cOffset;
end;
end;
然后你判断类名是不是窗口类
用定时器的方法比较实在点
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 100;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
MousePos: TPoint;
begin
GetCursorPos(MousePos);
if PtInRect(Self.BoundsRect, MousePos) then
Caption := '鼠标在窗体上'
else
Caption := '鼠标不在窗体上';
end;end.