Is it possible to create a window with just a close button

I’m currently writing my own GUI library with OpenGL and I’m trying to implement message boxes.

If I disable resizing it just disables the maximize button, but the minimize (or iconify as glfw calls it) is still interactable. I would prefer it when the buttons weren’t visible at all, like in “true” windows message boxes. Is there a way to disable/hide these buttons?

You cannot do that with just GLFW. But if you’re OK with using OS specific API you can get access to native window handle by using functions in glfw3native.h and modify its style depending on platform.

For example on Windows you can get HWND by calling glfwGetWin32Window and then you can remove min/max button by removing WS_MAXIMIZEBOX and WS_MINIMIZEBOX from window style:

SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtrA(hwnd, GWL_STYLE) & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
1 Like

@mmozeiko’s solution is likely the best, but you could also use a non decorated window and add the close widget yourself - Dear ImGui uses this for the docking branch external windows and it works well, though they are not natively styled.

@mmozeiko Solution works at least on Windows. I’m more of a fan of that solution as I don’t want to do custom titlebars yet. I have to look into how to disable the buttons with x11 though because I primarly use linux at home.