Windows任务栏可能具有状态"自动隐藏"。
有人知道在动画期间如何使用Windows任务栏使用QT进行检测吗?
如果这是不可能的,也许有办法检测任务栏切换状态是从隐藏显示还是显示或反对?
答案 0 :(得分:0)
如果您想对Qt中的任务栏进行更改(不仅是在自动隐藏,还有用户移动和/或调整任务栏大小),您可以这样做:
void MainWindow::workAreaResized()
{
//Get handle of taskbar
HWND hTaskbarWnd = FindWindow(TEXT("Shell_TrayWnd"), NULL);
//Get info about screen that the taskbar lives
HMONITOR hMonitor = MonitorFromWindow(hTaskbarWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO info = {sizeof(MONITORINFO)};
if (GetMonitorInfo(hMonitor, &info))
{
//Get taskbar rect info
RECT rect;
GetWindowRect(hTaskbarWnd, &rect);
//Calculate screen size
int screenwidth = info.rcMonitor.right - info.rcMonitor.left;
int screenheight = info.rcMonitor.bottom - info.rcMonitor.top;
//Calculate top-left position
int left = qMax(info.rcMonitor.left, rect.left);
int top = qMax(info.rcMonitor.top, rect.top);
//Calculate taskbar rectangle visible on the screen
QRegion taskbar = QRegion(left, top, qMin((LONG)screenwidth, rect.right) - left, qMin((LONG)screenheight, rect.bottom) - top);
//Get a rectangle of the screen
QRegion screen = QRegion(info.rcMonitor.left, info.rcMonitor.top, screenwidth, screenheight);
//Get the available area rect (the screen rectangle subtracted the taskbar rectangle)
QRect workarea = screen.subtracted(taskbar).rects().first();
//If work area is different than the actual window rectangle, move and/or resize it
if (workarea.topLeft() != pos() || workarea.size() != size())
{
move(workarea.topLeft());
resize(workarea.width() - (frameGeometry().width() - width()),
workarea.height() - (frameGeometry().height() - height()));
}
}
}
调用该函数,变量QRect workarea
将包含任务栏所在的屏幕上的可用区域,此时您调用该函数。
答案 1 :(得分:0)
您可以使用SHAppBarMessage ABM_GETSTATE来获取任务栏的状态。