Sign in to follow this  

Locking the window size

This topic is 3459 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

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:



case WM_GETMINMAXINFO:

MINMAXINFO *minMaxInfo;

// 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

This topic is 3459 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this