Removing the maximize button from a window created using glfw

安稳与你 提交于 2019-12-10 11:11:09

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/8034053/removing-the-maximize-button-from-a-window-created-using-glfw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!