Click here to Skip to main content
15,881,882 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:

C++
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?
Posted
Updated 27-Aug-22 17:54pm
Comments
[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...
—SA

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:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx[^].

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

—SA
 
Share this answer
 
Comments
ShahadBattar 25-Apr-13 17:02pm    
I'll check it
thank you
Sergey Alexandrovich Kryukov 25-Apr-13 17:20pm    
Great.
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.
—SA
Espen Harlinn 25-Apr-13 18:35pm    
5'ed!
Sergey Alexandrovich Kryukov 25-Apr-13 18:42pm    
Thank you, Espen.
—SA
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
 
Comments
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