|
|||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThe For each control left, top, width and height is specified, to determine how the position and size of the control windows will change when the size of the parent window changes. left specifies the change in the position of the left edge of the object relative to the total change in the parent window’s width. top specifies the change in the top position of the object relative to the total change in the parent window’s height. width specifies the change in the width of the object relative to the total change in the parent window’s width. height specifies the change in the height of the object relative to the total change in the parent window’s height. The valid range for each parameter is 0 to maxPart, but also the sum of left + width and top + height must be less than or equal to maxPart In general, the following formula is used newValue = oldValue + (( deltaValueParent * partValue) / maxPart ) where:
The default value for maxPart is 100, for a better degree of granularity another value can be specified in the Constructor or Create method Example :// Create the control m_resize.Create( this ); // Add the controls to be resized // l t w h m_resize.Add( IDC_EDIT1, 0, 0, 100, 50 ); m_resize.Add( IDC_LIST1, 0, 50, 100, 50 ); m_resize.Add( IDOK, 50, 100, 0, 0 ); // Use the current width and height // for minimum tracking size m_resize.SetMinimumTrackingSize();
When the width of the parent's window increases by 40 pixels and the height increases by 20 pixels: IDC_EDIT1: left += 0 top += 0 width += 40 height += 10 IDC_LIST1: left += 0 top += 10 width += 40 height += 10 IDOK : left += 20 top += 20 width += 0 height += 0 Usage :Add the file 'ResizeCtrl.cpp' and 'ResizeCtrl.h" to your project Include "ResizeCtrl.h' in the associated header file and add the #include "ResizeCtrl.h" class CDemoDialog : public CDialog { // other stuff CResizeCtrl m_resize; //.... In BOOL CDemoDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// Create the control
m_resize.Create( this );
// Add the controls to be resized
// l t w h
m_resize.Add( IDC_EDIT1, 0, 0, 100, 50 );
m_resize.Add( IDC_LIST1, 0, 50, 100, 50 );
m_resize.Add( IDOK, 50, 100, 0, 0 );
// Use the current width and height
// for minimum tracking size
m_resize.SetMinimumTrackingSize();
orBOOL CDemoDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// Create the control
m_resize.Create( this );
// Add the controls to be resized
CResizeInfo rInfo[] =
{
// id l t w h
{ IDC_EDIT1, 0, 0, 100, 50 },
{ IDC_LIST1, 0, 50, 100, 50 },
{ IDOK, 50, 100, 0, 0 },
{ 0 },
};
m_resize.Add( rInfo );
// Use the current width and height
// for minimum tracking size
m_resize.SetMinimumTrackingSize();
Because
|
||||||||||||||||||||||||||||||||