zoukankan      html  css  js  c++  java
  • 判断指定窗口是否被其他窗口遮挡

    转载:https://www.cnblogs.com/findumars/p/5086797.html

    bool CTestTray2Dlg::IsCoveredByOtherWindow(HWND hWnd)
    {
     RECT rcTarget; 
     ::GetWindowRect(hWnd, &rcTarget);
    
     bool isChild = (WS_CHILD == (::GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD));
    
     if (::GetDesktopWindow() == hWnd)
      hWnd = ::GetWindow(::GetTopWindow(hWnd), GW_HWNDLAST);
    
     do{ 
      HWND hCurWnd = hWnd;
    
      while(NULL != (hWnd = ::GetNextWindow(hWnd, GW_HWNDPREV))){ 
       if (::IsWindowVisible(hWnd)){ 
        RECT rcWnd; 
        ::GetWindowRect(hWnd, &rcWnd);
    
        if(!((rcWnd.right < rcTarget.left) || (rcWnd.left > rcTarget.right) || 
         (rcWnd.bottom < rcTarget.top) || (rcWnd.top > rcTarget.bottom))){ 
         return true; 
        } 
       } 
      }
    
      if(isChild){ 
       hWnd = ::GetParent(hCurWnd); 
       isChild = hWnd ? (WS_CHILD == (::GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)) : false; 
      } 
      else 
       break; 
     }while(true);
    
     return false;
    }

    大意是自底向上层层遍历窗口,检查是否有窗口与指定窗口有重叠的地方。

  • 相关阅读:
    10.18
    10.16~10.17笔记
    JS
    10.8~10.11
    9.28~9.29
    9.27 代码笔记
    代码复习(9.26)
    9.19 链家
    9.18笔记
    9.17 定位
  • 原文地址:https://www.cnblogs.com/Toya/p/13140988.html
Copyright © 2011-2022 走看看