PDA

View Full Version : Restricting window size in Win32 OGL App



Iceman
12-06-2001, 04:38 PM
I am using NeHe's Win32 framework for a setup/launcher app to be used for setup and launching of another OpenGL based application (just like Descent3's launcher). I start the launcher, blit an image to the background, and draw selectable objects on top of the image that have various behaviors when clicked. All is well with just one problem ...

The user can resize the window. I need to be able to restrict the window to the background image size of 640x480. Anyone know how to force a Win32 window to be a fixed size? I'm sure this won't take more than a few lines of code but, having little Win32 app dev experience I don't know where to look for help. I have searched the MSDN docs and found nothing suitable. Any help would be appreciated including keywords to search for and techniques.

Platinum
12-06-2001, 05:57 PM
Change the window style. If you use the Nehe framework, then find CreateWindow (or CreateWindowEx) and change the third (or fourth) parameter to for example WS_POPUP or WS_OVERLAPPED (NOT the version with -WINDOW in behind, for ex. WS_OVERLAPPEDWINDOW, that will create the sizeable border). Have a look at this in MSDN, there are many other options for window style.

Iceman
12-06-2001, 07:11 PM
Thanks a lot that worked ... here is my code :




dwExStyle =
WS_EX_APPWINDOW|WS_EX_WINDOWEDGE|WS_EX_CLIENTEDGE;

dwStyle = WS_BORDER|WS_CAPTION;

AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);

// Create The Window
if (!(hWnd=CreateWindowEx(
dwExStyle,
"OpenGL",
title,
dwStyle|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
0,
0,
WindowRect.right-WindowRect.left,
WindowRect.bottom-WindowRect.top,
NULL,
NULL,
hInstance,
NULL)))
{
KillGLWindow();
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

Iceman
12-06-2001, 07:15 PM
I had to add an option for the close box ...

Thanks again http://www.opengl.org/discussion_boards/ubb/smile.gif




dwStyle=WS_BORDER|WS_CAPTION|WS_SYSMENU;