Click to See Complete Forum and Search --> : [RESOLVED] How to ensure controls on a window will be resize?


light85
June 26th, 2009, 01:38 PM
I have created a window in WinMain and added a few buttons onto the window.

But when i resize the window the buttons remains, how do i make the buttons resize too?

The example i read use WM_SIZE but it is for dialog box.

Do i have to use WM_SIZE? if so how do i go about it?

JVene
June 26th, 2009, 02:09 PM
It's not that simple.

Here's the situation. Each control IS window (usually, there are various and generally rare exceptions - in those cases though they are text/graphics drawn in a particular region OF the a window).

For the common situation, each control-window has a position and a size of it's own. If you resize the parent window, all that happens is the parent window's dimensions change. The coordinates of each child window remain the same. You either end up with a smaller parent, chopping the area upon which the children display (cropping them), or you end up with empty space on the parent dialog.

In order for the child controls to resize, each one must be repositioned and resized. There's no simple way to just have it done, unless you use a library that supports the concept.

light85
June 26th, 2009, 11:54 PM
So, should I use WM_CREATE instead or should i create a dialog.
As i want to have the controls on the window itself.

JVene
June 27th, 2009, 12:05 AM
The basic plan is to respond to the WM_SIZE message, then reposition every control on the window.

light85
June 27th, 2009, 12:08 AM
Ok, then i'll create the buttons using WM_CREATE instead. Thanks.