How do i programatically resize a window ?
Using windows programming with msvc++ 6, I have code that handles a window resize in my wndproc like this:
case WM_SIZE:
// ....
return 0;
break;
I want to be able to have some control over what sizes the user can make the window though. For instance, if window is currently 300 X 400, and the user resizes its length only, say to 100 X 400, I want to be able to say " hey, thats too skinny " and resize it to 200 X 400, for example.
someone in another forum told me to look up sendmessage() and postmessage(), but I had a hard time finding info on these functions.
Can anyone tell me how do accomplish this, or point me to a good reference to the sendmessage() or postmessage() functions?
by the way, please dont just say " look on msdn ", because every single time i look for information there, i never find it. I dont think that site is organized very well. i dont even know where to start.
anyway, thanks in advance!
Its not my fault I''''m the biggest and the strongest; I don''''t even exercise.
Its not my fault I''m the biggest and the strongest; I don''t even exercise.
A bit rusty on this, and do not have time testing it. But you can override the WM_SIZE message and not passing it over to DefWindowProc(), and thereby stopping the window from resizing, right? Or is that another message?
Using this technique you can override when the user resize the window to a size greater than your maximum, and instead post yourself a message with the maximum size. Not sure though. You get the new/proposed size together with WM_SIZE, but how, that you have to look up in MSDN
Isn''t there a attribute or something that sets a window''s min/max width/height?
Sorry, didn''t end up very helpful. Someone who really knows the answer could perhaps take on this.
Using this technique you can override when the user resize the window to a size greater than your maximum, and instead post yourself a message with the maximum size. Not sure though. You get the new/proposed size together with WM_SIZE, but how, that you have to look up in MSDN
Isn''t there a attribute or something that sets a window''s min/max width/height?
Sorry, didn''t end up very helpful. Someone who really knows the answer could perhaps take on this.
The corrolary to what CWizard said is the SetWindowPos API.
I agree with you that MSDN could be better organized. The search query always ends up inserting marketing crap from other places. For example, just yesterday I went looking for the docs pertaining to GDI+ and the search returned a dozen links specific to WinCE - ??? Not only that, all those frames make for very slow navigation.
Try starting from here: MSDN Library
Here is the entry for: SetWindowPos
Another trick is to let google handle the dirty work of sorting through the MS mess for you. In the future when someone suggests a particular Win32 API to look into, plug the name into google and see what comes up. Chances are very high that the correct MSDN page will be listed on the first set of returns - unless the API is undocumented.
I agree with you that MSDN could be better organized. The search query always ends up inserting marketing crap from other places. For example, just yesterday I went looking for the docs pertaining to GDI+ and the search returned a dozen links specific to WinCE - ??? Not only that, all those frames make for very slow navigation.
Try starting from here: MSDN Library
Here is the entry for: SetWindowPos
Another trick is to let google handle the dirty work of sorting through the MS mess for you. In the future when someone suggests a particular Win32 API to look into, plug the name into google and see what comes up. Chances are very high that the correct MSDN page will be listed on the first set of returns - unless the API is undocumented.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
quote: Original post by CWizard
A bit rusty on this, and do not have time testing it. But you can override the WM_SIZE message and not passing it over to DefWindowProc(), and thereby stopping the window from resizing, right?
wm_size is handled after the window is already resized.
quote:
Or is that another message?
yup, what you''re looking for is WM_GETMINMAXINFO.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement