Advertisement Jump to content
Sign in to follow this  

Locking the window size

This topic is 3864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there, I'm using Win32 with Direct3D in windowed mode and I want to know how to prevent my window from resizing. Is it possible?

Share this post

Link to post
Share on other sites
Yes, look up WM_SIZING. You can alter the RECT to keep it at a minimum or maximum size.

Alternatively, if you want a fixed size, you can use the window style during CreateWindow(). Typically you'll create an WS_OVERLAPPEDWINDOW window, which is short for WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX.

WS_THICKFRAME makes the border sizable, so just leave that out. May have to experiment a bit to get the desired style.

Share this post

Link to post
Share on other sites
Alternatively, you can use the MINMAXINFO struct to tell the window to have a size restriction:



// Force a minimum of 250x250 pixel size window
minMaxInfo = (MINMAXINFO *) lParam;
minMaxInfo->ptMinTrackSize.x = 250;
minMaxInfo->ptMinTrackSize.y = 250;

if (lockWindowSize)
minMaxInfo->ptMinTrackSize.x = minWidth;
minMaxInfo->ptMinTrackSize.y = minHeight;
minMaxInfo->ptMaxTrackSize.x = maxWidth;
minMaxInfo->ptMaxTrackSize.y = maxHeight;

return FALSE;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!