Resizing controls

Started by Robert Rioja, December 28, 2009, 03:42:41 PM

Previous topic - Next topic

Robert Rioja

How do I resize controls in a form which is in a tab?
I have a main form which contains a tab control.  Each tab has a form assigned to its Child Page Dialog.  Each of these forms has controls.  When the main form is resized at run time, I resize the tab control and each child form is resized.  But I cannot figure out how to resize the controls in the child forms.

Any ideas?

Robert

Paul Squires

You resize the controls by responding to the WM_SIZE message handler for the tab control child form that the specific controls are actually on.
Paul Squires
PlanetSquires Software

Robert Rioja

I already did that and it does not work.  I attached a zip with a sample project.  There are controls in the first two child forms.  The code is identical for all controls.  Yet the two forms resize the controls differently.  Also, if you make the main form very large, the child forms stop growing at a certain point.

Robert

Rolf Brandt

Hi,

here is the project back. I guess it works now the way you expect it.

I moved the sizing code from WM_CREATE to WM_SIZE.

I added the following code in the frmMain WM_SIZE:
   'Code provided by Paul Squires
   Tab_Notify.hwndFrom = HWND_FRMMAIN_TABMAIN
   Tab_Notify.Code     = %TCN_SELCHANGING
   SendMessage hWndForm, %WM_NOTIFY, IDC_FRMMAIN_TABMAIN, VarPtr(Tab_Notify)
   Tab_Notify.Code     = %TCN_SELCHANGE
   SendMessage hWndForm, %WM_NOTIFY, IDC_FRMMAIN_TABMAIN, VarPtr(Tab_Notify)


Project CheckBookFF1.zip is attached.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Robert Rioja

Thank you Rolf.  Where did the code you added come from?  How is one to know that it is needed?  Is it covered in the help somewhere?

Thanks again,
Robert

Rolf Brandt

Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Cho Sing Kum

#6
I am also grappling with the same situation for the child forms. They are not automatically resized properly "on the fly" when the tab is being resized. You will notice this when you click on another tab after a resize.

The last few tabs in the sample are blank except for the child forms so they are good place for checking this out. You will notice that they extend over the taskbar everytime after a resize when they are not the active tab - click on the tabs after a resize to see this.

I work around this by trying to resize ALL child forms in code in the tab's wm_size. And have to size their height 30 smaller then the tab's nHeight (new height of client area).


Cho Sing Kum

#7
I think I got it figured out. I went back to my VB6 codes to refresh what I did there.

When using a Statusbar in FF3, I need to deduct its height when resizing the main form.

I attach zip of 2 sample projects - with and without Statusbar. ListView is used as child control in the child forms.

Rolf Brandt

Yes, they work perfectly. Similar if you use a toolbar you have to deduct its height too.
I was lost without Paul's code snippet.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)