This tutorial is going to be short but it's surely handy. I've been asked these questions at least five times: "How do I make my window non-resizable?" and "How do I remove the minimize and/or maximize buttons from the title bar menu?". Luckily, all of this(and more) can be done during process of creating the window with the function CreaetWindowEx.
As you've observed in the previous tutorials the fourth parameter of the function takes window style flags. By OR'ing various flags you can achieve the desired style. In previous tutorials only one flag was used and it was WS_OVERLAPPEDWINDOW. This one long flag is actually a collection of flags OR'ed(using the bitwise OR operator) together and not just one style.
WS_OVERLAPPEDWINDOW contains all of the following styles in one:
As you saw in previous tutorials this creates a general-looking window with a title bar which shows the name of the window and the three "system" buttons - minimize, maximize and close. I'll quickly go over the styles by introducing you to this image below and then explain what style does what.
WS_OVERLAPPED creates a window with a title bar. The three flags located in the upper right corner of the image indicate which system buttons will appear. If in any case you don't want the user to see(and use) the minimize and maximize buttons only specify the WS_SYSMENU style.
WS_BORDER adds a border to your window. To make this border "thick" (there are two kinds of borders - normal and thick) add WS_THICKFRAME style; a thick frame I believe is 2 more pixels thicker.
This is some really straightforward stuff. For example if you wanted to create a window that only has a close button and will not be resizable and have a normal border thickness, you would pass the following flags to the CreateWindowEx function:
// Create the window
hwnd = CreateWindowEx(NULL,
Note there is no source code for this tutorial because it's too simple.
© 2014 OpenGL Tutorials.