各位网友大家好!
   我想实现类似QQ的窗体隐藏功能(鼠标放上去显示,挪开就隐藏),基本功能是实现了,可是现在只能识别窗体,而窗体上的控件就不行了。鼠标放到控件上,窗体就隐藏了。如何才能让窗体上的所有控件也能识别鼠标,等鼠标彻底离开窗口后再隐藏。先谢谢了.由于我积分已经只有14分了,所以没有办法给大侠们分了,还请多多包涵!谢谢!

解决方案 »

  1.   

    procedure TFm_Counter_Main.tmrHide_ShowWindowTimer(Sender: TObject);
    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;
      

  2.   

    放一个定时器,用GetCursorPos获取当前鼠标位置,然后判断这个位置是否在窗体上就行了。
      

  3.   

    WindowFromPoint 可以的
    然后你判断类名是不是窗口类 
      

  4.   

    WindowFromPoint 只对有句柄的控件有效
    用定时器的方法比较实在点
      

  5.   

    我用的就是Timer啊。还有别的定时器吗?
      

  6.   

    楼主试试
    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.