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等函数有时失败,无法将窗口带到前台的问题。 以上是据说是微软的标准调用代码,包试包灵,童叟无欺,解决了困扰我很久的问题,有需要的赶紧收下吧!
  • 相关阅读:
    原生小程序音频播放
    Vue定义全局过滤器filter
    系统扩展性之引入外部包
    oracle update join
    OAuth2
    oracle pl/sql
    MySQL同步工具otter的使用介绍(一)
    python批量安装apk
    mac brew安装redis
    antd 修改Modal的底部按钮颜色
  • 原文地址:https://www.cnblogs.com/fwycmengsoft/p/3008616.html
Copyright © 2011-2022 走看看