C++代码
1
2
3
4
5
6
7
8
9
10
11
12
13
BOOL SetTopWindow(HWND hWnd)
 {
    HWND hForeWnd = GetForegroundWindow();
    DWORD dwForeID = GetWindowThreadProcessId(hForeWnd, NULL);
    DWORD dwCurID = GetCurrentThreadId();
    AttachThreadInput(dwCurID, dwForeID, TRUE);
    ShowWindow(hWnd, SW_SHOWNORMAL);
    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
    SetForegroundWindow(hWnd);
    AttachThreadInput(dwCurID, dwForeID, FALSE);
    return TRUE;
 }
描述:一个解决SetForegroundWindow和BringWindowToTop等函数有时失败,无法将窗口带到前台的问题。 以上是据说是微软的标准调用代码,包试包灵,童叟无欺,解决了困扰我很久的问题,有需要的赶紧收下吧!

相关文章:

  • 2022-12-23
  • 2021-09-08
  • 2021-07-21
  • 2023-03-18
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-01-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-07-15
  • 2021-09-20
相关资源
相似解决方案