How can I force a window to be unresizeable

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

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

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.

That is true, but I think he wanted to stop the user from resizing the window.

Mikael

Originally posted by mikael_aronsson:
[b]That is true, but I think he wanted to stop the user from resizing the window.

Mikael[/b]
Window 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.

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 );