不知道你的具体应用是什么
windowfrompoint,可以试试
如果你指的是自己的窗体,那很好办
你可以截获整个应用程序的wm_lbuttondown
然后就好处理了,用什么都可以,比如还用windowfrompoint如果是截获别的程序,用hook吧

解决方案 »

  1.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      i:TPoint;
      winhandle:hwnd;
      tt,te:Pchar;
    begin
      GetCursorPos(i);
      winhandle:=WindowFromPoint(i);
      GetMem(te,256);
      GetMem(tt,256);
      GetWindowText(winhandle,te,256);
      GetWindowText(GetParent(Winhandle),tt,256);
      label2.Caption:='类名:'+GetWinClassName(winhandle)+#13
                      +'标题:'+te+#13
                      +'父窗口标题:'+tt;  FreeMem(tt,256);
      FreeMem(te,256);
    end;
      

  2.   

    用 WindowFromPoint ,没错。
      

  3.   

    可是我要的是鼠标按下的POS,而且我的窗体上铺满了控件
      

  4.   

    Tapplicationevent.    可以的!他可以截获所有控件的消息
      

  5.   

    以下代码摘自:
    http://www.delfan.com/delphi/simplespy.html
    ==================================================================
    新建工程,窗体上放置一个Button,一个Edit.使用方法:先点击button,然后点击想要得到句柄的窗体.下面是代码
    unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type 
      TForm1 = class(TForm) 
        Button1: TButton; 
        Edit1: TEdit; 
        procedure Button1Click(Sender: TObject); 
        procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 
      private 
      { Private declarations } 
      public 
      { Public declarations } 
      end; var Form1: TForm1; implementation {$R *.DFM} 
    procedure TForm1.Button1Click(Sender: TObject); 
    begin 
      setcapture(handle); // 设置捕获鼠标输入 
    end; procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 
    var point : TPoint; 
        hwnd : THandle; 
    begin 
      point.x := x; 
      point.y := y; 
      point := ClientToScreen(point); // 客户区坐标转换到屏幕坐标 
      hwnd := WindowFromPoint(point); // 取鼠标点击的窗体句柄 
      ReleaseCapture; // 终止捕获鼠标输入 
      if hwnd=handle then edit1.text := '没有点击其他窗体!' 
      else 
        edit1.Text := inttostr(hwnd); // 将捕捉到的窗体句柄显示在edit1中
    end; end.