PDA

View Full Version : How can I force a window to be unresizeable



NeoRc
02-19-2005, 09:15 AM
Using GLUT, even I don't register a ReshapeFunc, a default reshape function is called, which calls glViewport(0, 0, width, height).

However, can I force the window cannot be resized?

--NeoRc

mikael_aronsson
02-19-2005, 09:59 AM
Hi !

I am not sure, but as far as I know you cannot stop a window from being resized with glut unless you start to poke around with OS specific code.

Mikael

MMMovania
02-19-2005, 06:20 PM
Well it can be done. You can create a Reshape function and set the viewport and window to your required size. This way whenever the user resizes the window, the contents would not change.

mikael_aronsson
02-20-2005, 05:19 AM
That is true, but I think he wanted to stop the user from resizing the window.

Mikael

MMMovania
02-20-2005, 08:42 AM
Originally posted by mikael_aronsson:
That is true, but I think he wanted to stop the user from resizing the window.

MikaelWindow resizing can be stopped using the glutReshapeWindow function. Do the following in your reshape function.

//Assuming you want to set window size to 400x400
void Reshape(int nWidth, int nHeight)
{
glutReshapeWindow(400,400);
}

Hope this will solve your problem. Note that doing so allows user to see the resize cursor and mask line but the window does not resize.

plasmonster
02-20-2005, 09:13 AM
As Mikael said, the only way to do this gracefully is to deal with the windowing system directly. Fortunately, this isn't difficult at all. You just need to poke around in the windows docs.

Add this code right after glutCreateWindow, before the main loop:

if( HWND hWnd = WindowFromDC(wglGetCurrentDC()) )
SetWindowLong( hWnd, GWL_STYLE, (DWORD)GetWindowLong( hWnd, GWL_STYLE ) & ~WS_SIZEBOX );