zoukankan      html  css  js  c++  java
  • (C++)窗口置前SetForegroundWindow(pThis->hwndWindow);

    一段代码主要是创建一个Window,然后将其置顶显示。奇怪的是这个功能有时候无效。

                            pThis->bWindowDisplayed = SetForegroundWindow(pThis->hwndWindow);


    查MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633539(v=vs.85).aspx 看来需要满足的条件不少。

    网上解决方法:

    HWND hForeWnd = NULL; 
    HWND hWnd= FindWindow(NULL, ""); 
    DWORD dwForeID; 
    DWORD dwCurID; 
     
    hForeWnd =  GetForegroundWindow(); 
    dwCurID =  GetCurrentThreadId(); 
    dwForeID =  GetWindowThreadProcessId( hForeWnd, NULL ); 
    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);
  • 相关阅读:
    Java基础知识:正则表达式
    NodeJs 中 将表单数据转发到后台
    单片机的远程升级
    一些开源协议
    物联网的一些例子
    python一些开源特色库
    qt练习
    网页编程学习笔记
    PCB相关
    工业控制系统
  • 原文地址:https://www.cnblogs.com/fdyang/p/5158675.html
Copyright © 2011-2022 走看看