zoukankan      html  css  js  c++  java
  • 解决SetForegroundWindow和BringWindowToTop等函数有时失败,无法将窗口带到前台的问题

    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等函数有时失败,无法将窗口带到前台的问题。 以上是据说是微软的标准调用代码,包试包灵,童叟无欺,解决了困扰我很久的问题,有需要的赶紧收下吧!
  • 相关阅读:
    启智树提高组Day4T3 2的幂拆分
    拉格朗日插值
    #3342. 「NOI2020」制作菜品
    P6776 [NOI2020]超现实树
    P6773 [NOI2020]命运
    P5298 [PKUWC2018]Minimax
    每日总结5.20
    每日总结5.19
    每日总结5.18
    每日总结5.17
  • 原文地址:https://www.cnblogs.com/fwycmengsoft/p/3008616.html
Copyright © 2011-2022 走看看