WinAPI: stop window getting too small

Started by
3 comments, last by BlackBox 15 years, 6 months ago
hi Everyone, Does anyone knows how to stop a WinApi window getting to small? Many Thanks.
---------------------------- ^_^
Advertisement
capture the WM_SIZE message and dont let the window size go below what you specify
Quote:Original post by ncsu121978
capture the WM_SIZE message and dont let the window size go below what you specify


i have tried something like this:

if(uMsg == WM_SIZE){	// Resize The Window    if(HIWORD(lParam) < 100) return 0;    if(LOWORD(lParam) < 100) return 0;    ....


Didnt worked.... Any idea what I'm doing wrong?

Thanks.
---------------------------- ^_^
You should instead capture the WM_GETMINMAXINFO message.
Something like this:
case WM_GETMINMAXINFO: {	LPMINMAXINFO	mmi = reinterpret_cast<LPMINMAXINFO>(lParam);		mmi->ptMinTrackSize.x = min_x_size;	mmi->ptMinTrackSize.y = min_y_size;} return 0;


For most messages, you should always return zero when you handle them. Only for a few messages, such as WM_CREATE for example, does the return value change much. If you look up the MSDN page for the message you can see what you're supposed to return.
For the WM_GETMINMAXINFO: http://msdn.microsoft.com/en-us/library/ms632626(VS.85).aspx

EDIT: If you visit that webpage, and select WM_SIZE in the left column instead, you will see that it says WM_SIZE is only sent after the window is resized, which is why it's not a good idea to use that message.
You might also want to check out the WM_SIZING message, which allows for controlling the size of the window.
Quote:Original post by Erik Rufelt
You should instead capture the WM_GETMINMAXINFO message.
Something like this:
case WM_GETMINMAXINFO: {	LPMINMAXINFO	mmi = reinterpret_cast<LPMINMAXINFO>(lParam);		mmi->ptMinTrackSize.x = min_x_size;	mmi->ptMinTrackSize.y = min_y_size;} return 0;


For most messages, you should always return zero when you handle them. Only for a few messages, such as WM_CREATE for example, does the return value change much. If you look up the MSDN page for the message you can see what you're supposed to return.
For the WM_GETMINMAXINFO: http://msdn.microsoft.com/en-us/library/ms632626(VS.85).aspx

EDIT: If you visit that webpage, and select WM_SIZE in the left column instead, you will see that it says WM_SIZE is only sent after the window is resized, which is why it's not a good idea to use that message.
You might also want to check out the WM_SIZING message, which allows for controlling the size of the window.


It works prefectly .... *rates Erik as extremly helpful*

Many Many Thanks.
---------------------------- ^_^

This topic is closed to new replies.

Advertisement