Is it possible to set the taskbar position/width/height using the windows API? I'm running 3 monitors and I want to prevent the taskbar from spanning across all monitors and not stay on top all the time.
Here is what I have attempted so far with no luck... I'm not sure if there is something wrong with my code or it's just being blocked.
#include <iostream>
#include "Windows.h"
using namespace std;
class MyClass
{
public:
int getTaskBarHeight();
void setTaskBarPos();
};
int MyClass::getTaskBarHeight()
{
RECT rect;
HWND taskBar = FindWindow(L"Shell_traywnd", NULL);
if(taskBar && GetWindowRect(taskBar, &rect)) {
return rect.bottom - rect.top;
}
}
void MyClass::setTaskBarPos()
{
RECT rect;
HWND taskBar = FindWindow(L"Shell_traywnd", NULL);
if(taskBar && GetWindowRect(taskBar, &rect)) {
SetWindowPos(taskBar, HWND_TOPMOST, 0, 0, 1080, 46, SWP_NOZORDER);
}
}
int main(void)
{
MyClass taskbar;
cout << taskbar.getTaskBarHeight();
taskbar.setTaskBarPos();
int a;
cin >> a;
}
To answer the "Spanning accross all 3 displays" question, this is normally down to the configuration of the display adapter. You can have 3 individual displays (1 per monitor), or 1 big display spanning accross all three monitors. The latter sounds like your situation, and Windows offers no way to make an app bar only take up part of a display.
Your best bet is to adjust the display driver to create 3 indiividual displays rather than 1 big one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.