Click here to Skip to main content
15,936,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using C++ openGL and I need my window size to remain constant.
I've used the following function to disable the maximize button:

void toggleGlutWindowMaximizeBox(char *szWindowTitle)
    long dwStyle;
    HWND hwndGlut;
    hwndGlut = FindWindow(NULL, szWindowTitle);
    dwStyle = GetWindowLong(hwndGlut, GWL_STYLE);
    dwStyle ^=WS_MAXIMIZEBOX;
    SetWindowLong(hwndGlut, GWL_STYLE, dwStyle);

It did work =) the button appeared gray but still the size of the window can be manipulated through its borders!

I googled it a lot but still I couldn't find anything useful.

Can anyone help?
Updated 27-Aug-22 17:54pm
[no name] 25-Apr-13 13:37pm    
You would need to set the window border style.
ShahadBattar 25-Apr-13 14:16pm    
and how can I do that?
which library should I link with?
Sergey Alexandrovich Kryukov 25-Apr-13 16:21pm    
How on Earth could it be related to OpenGL? This is just the Windows API...

You were really, really close. You picked unrelated style, controlling maximize operation. Resizing by the border is controlled by another bit, WS_SIZEBOX, same as WS_THICKFRAME. You have to clear this bit. Please see:[^].

Likewise, you could take care about removing of minimize box and some other things. Please look by yourself.

Share this answer
ShahadBattar 25-Apr-13 17:02pm    
I'll check it
thank you
Sergey Alexandrovich Kryukov 25-Apr-13 17:20pm    
When you get the fix, please don't forget to accept the answer formally (green button).
In all cases, you are welcome to ask your follow-up questions.
Espen Harlinn 25-Apr-13 18:35pm    
Sergey Alexandrovich Kryukov 25-Apr-13 18:42pm    
Thank you, Espen.
Process Non-Client HitTest

Add ON_WM_NCHITTEST() to MessageMap

LRESULT OnNcHitTest(CPoint point)
LRESULT oHitItem= __super::OnNcHitTest(point);
if(oHitItem >= HTSIZEFIRST && oHitItem <= HTSIZELAST)
return HTCLIENT;

return oHitItem;
Share this answer
Dave Kreskowiak 28-Aug-22 0:03am    
Unexplained code snippets are not answers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900