Question

How do you remove the maximize button from a window created usingg the glfwopenWindow functionn call ?

Currently, what I'm doing is:

windowHandle = GetForegroundWindow();
long Style = GetWindowLong(windowHandle, GWL_STYLE);
Style ^= WS_MAXIMIZEBOX;
SetWindowLong(windowHandle, GWL_STYLE, WS_MAXIMIZEBOX);

Where, I get the window handle and then toggle the maximize bit. Then I re-apply the window style. But this doesn't work an it makes the window completely blank without any buttons or title bar. is there anyway to remove the maximize button. I dont want to change the window size whenever the resize function is called

Was it helpful?

Solution

you code is bugged, as you don't pass back the old style, thus clearing all the style flags except WS_MAXIMIZEBOX, it should read:

windowHandle = GetForegroundWindow();
long Style = GetWindowLong(windowHandle, GWL_STYLE);
Style &= ~WS_MAXIMIZEBOX; //this makes it still work when WS_MAXIMIZEBOX is actually already toggled off
SetWindowLong(windowHandle, GWL_STYLE, Style);

also, you should really use the GetWindowlongPtr based functions if you plan on any future x64 compatability

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top