How to detect if autohidden taskbar is visible or not?

后端 未结 1 1585
终归单人心
终归单人心 2020-12-18 15:42

At the moment I need to detect in C++/Qt if a taskbar, which is set to \"autohide\" is visible on the screen or not. I have tried already following solution, unfortunately w

相关标签:
1条回答
  • 2020-12-18 16:11
    HWND hTaskbarWnd = FindWindow("Shell_TrayWnd", null);
    bool isVisible = IsWindowVisible(hTaskbarWnd);
    

    or

    bool IsTaskbarWndVisible() {
    HWND hTaskbarWnd = FindWindow("Shell_TrayWnd", null);
    HMONITOR hMonitor = MonitorFromWindow(hTaskbarWnd , MONITOR_DEFAULTTONEAREST);
    MONITORINFO info = { sizeof(MONITORINFO) };
    if (GetMonitorInfo(hMonitor, &info))
    {
      RECT rect;
      GetWindowRect(hTaskbarWnd , &rect);
      if ((rect.top >= info.rcMonitor.bottom - 4) ||
          (rect.right <= 2) ||
          (rect.bottom <= 4) ||
          (rect.left >= info.rcMonitor.right - 2))
      return false;
    
      return true;
    }
    
    0 讨论(0)
提交回复
热议问题