I've found some more questions on StackOverflow about my topic. One of them is here.
I have also read the Microsoft Documentation about MINMAXINFO
and the message associated with this structure. I simply can't make it work... Here is what I've tried so far:
case WM_PAINT:
{
MINMAXINFO mmi = { 0 };
SendMessage(hWnd, WM_GETMINMAXINFO, NULL, (LPARAM)&mmi);
POINT sz = { 640, 480 };
mmi.ptMaxSize = sz;
}
break;
I think this is completely wrong, since it is not having any effect on the window...
How can I get this working, for a minimum size of W: 450, H: 250
, and a maximum of W:800, H: 600
?
Further explanation of the effect that I need: when the user drags one corner, or border of the window, and the window has the maximum/minimum size, the user cannot make the window larger or smaller than the minimum_size
/maximum_size
WM_GETMINMAXINFO
is a message that the system sends to a window. It sends that message when it wants to know the minimum and maximum allowable sizes are for the window. You never send that message. You can, however, respond to that message when it is sent to you.
So, you need to add a case for WM_GETMINMAXINFO
in your window procedure:
case WM_GETMINMAXINFO:
{
MINMAXINFO* mmi = (MINMAXINFO*)lParam;
mmi->ptMaxSize.x = 800;
mmi->ptMaxSize.y = 600;
return 0;
}
It turns out that you want to control the tracking size. Do that like so:
case WM_GETMINMAXINFO:
{
MINMAXINFO* mmi = (MINMAXINFO*)lParam;
mmi->ptMinTrackSize.x = 450;
mmi->ptMinTrackSize.y = 250;
mmi->ptMaxTrackSize.x = 640;
mmi->ptMaxTrackSize.y = 480;
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With