In my windows application, I am trying to find the height of the task bar. While I can hard program this into my program, I would like to find it programmatically to support past, present (win7) and future windows versions.
So, how would I do this?
In my windows application, I am trying to find the height of the task bar. While I can hard program this into my program, I would like to find it programmatically to support past, present (win7) and future windows versions.
So, how would I do this?
By searching google for "height of taskbar c++:, I got the following result.
From http://ahackersnotes.com/c/get-the-height-or-width-of-the-windows-taskbar-using-c.html
QUOTE: "Here’s how to get the height of the Windows task bar using the windows functions FindWindow and GetWindowRect.
int MyClass::getTaskBarHeight()
{
RECT rect;
HWND taskBar = FindWindow(L"Shell_traywnd", NULL);
if(taskBar && GetWindowRect(taskBar, &rect)) {
return rect.bottom - rect.top;
}
}
Getting the width (should the task bar be on the left or right of the screen) can be done using:
rect-right - rect.left"
EDIT: You may want to check if the width is greater than the height. If the width is greater, this means the bar is at the top or bottom. Otherwise, it is on the left/right side of the screen.
You get it from GetMonitorInfo(), MONITORINFOEX.rcWork. Get the HMONITOR from, say, MonitorFromRect(), passing your window rectangle. Or MonitorFromPoint() or EnumDisplayMonitors(), depends where you want to display your window. (0,0) is always the upper left corner of the primary monitor.
Ask Windows about it using the ABM_GETTASKBAR message and specifying the hwnd for the taskbar.