我想让我的程序只有在当前操作的时候,后台才接受数据
只要不是在当前,不管是最小化,还是到托盘,还是被别的程序覆盖,都不接受数据
最小化,到托盘,我可以用IsWindowsVisible来判断,但是比如别人把别的程序调到最前面,我就不会判断了
不知道如何判断,谢谢

解决方案 »

  1.   

    IsWindowEnabled
    The IsWindowEnabled function determines whether the specified window is enabled for mouse and keyboard input. BOOL IsWindowEnabled(
      HWND hWnd   // handle to window
    );试试这个
      

  2.   

    使用GetTopWindow传入NULL试试看。
      

  3.   

    你可以这样来试试看:
    HWND desWnd=::GetDesktopWindow();
    HWND topWnd=::GetTopWindow(desWnd);TCHAR t[30];
    _itot_s((int)topWnd, t,30, 10);
    OutputDebugString(t);
    OutputDebugString(_T("\n"));
    思路是获取桌面句柄,由桌面句柄获取桌面的最上层窗口。
      

  4.   


    HWND desWnd=::GetDesktopWindow();
    HWND topWnd=::GetTopWindow(desWnd);
    if(topWnd==this->m_hWnd)
    {
       //说明自己在顶层
    }