【问题标题】:System-wide focus全系统关注
【发布时间】:2009-08-10 09:32:30
【问题描述】:

是否可以获得当前焦点窗口的 HWND?对于整个 windows 站,不是当前的应用程序。目标应用程序是 Win32。我可以使用 :GetForegroundWindow() 获取当前窗口,但这只是主窗口。我可以枚举子窗口,但如何确定它是否具有焦点?

【问题讨论】:

    标签: windows winapi


    【解决方案1】:
    HWND RemoteGetFocus()
    {
       HWND hwnd = GetForegroundWindow();
       DWORD remoteThreadId = GetWindowThreadProcessId(hwnd, NULL);
       DWORD currentThreadId = GetCurrentThreadId();
       AttachThreadInput(remoteThreadId, currentThreadId, TRUE);
       HWND focused = GetFocus();
       AttachThreadInput(remoteThreadId, currentThreadId, FALSE);
       return focused;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 2022-01-23
      相关资源
      最近更新 更多