如题!

解决方案 »

  1.   

    只用GetFocus();是不行的,GetFocus();只能取得本程序内的焦点句柄,
    下面的函数可以取得所有程序的焦点句柄Function GetCurHandle:THandle;
    begin
      AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), True);
      Result := GetFocus();
      AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), False);
    end;
      

  2.   

    GenieWin(精灵太保) ( ) 信誉:99
    -----------------------------------------
    你的方法好像也不行,还有其它的方法吗?
    我要的是:获得整个屏幕中当前窗口的句柄,那个窗口可能是属于本程序,也可能是属于其它的window程序。
      

  3.   

    那你就用 SetForegroundWindow 吧.
    如果还是不行就用下面的:(加了GetParent)Function GetActiveHandle:THandle;
    begin
      AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), True);
      Result := GetParent(GetFocus());
      AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), False);
    end;
      

  4.   

    windows提供了这样的API,得到当前活动窗口的句柄.
      

  5.   

    那到底是哪个API撒?老大,讲讲吧
      

  6.   

    看来这个问题太偏了,把CSDN的老大们全难倒了。不好意思
      

  7.   

    函数原型:HWND GetActiveWindow(VOID)
    获得与调用线程的消息队列相关的活动窗口的窗口句柄。
    GetActiveWindow
    返回活动窗口句柄.
      

  8.   

    到这个地址
    http://www.fm201.com
    的 “下载中心”   看看,希望有帮助