CMFCDynamicLayout Class
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at CMFCDynamicLayout Class.
Specifies how controls in a window are moved and resized as the user resizes the window.
class CMFCDynamicLayout : public CObject
Public Constructors
| Name | Description |
|---|---|
CMFCDynamicLayout::CMFCDynamicLayout | Constructs a CMFCDynamicLayout object. |
CMFCDynamicLayout::~CMFCDynamicLayout | Destructor. |
Public Methods
| Name | Description |
|---|---|
| CMFCDynamicLayout::AddItem | Adds a child window, typically a control, to the list of windows that are controlled by the dynamic layout manager. |
| CMFCDynamicLayout::Adjust | Adds a child window, typically a control, to the list of windows that are controlled by the dynamic layout manager. |
| CMFCDynamicLayout::Create | Stores and validates the host window. |
| CMFCDynamicLayout::GetHostWnd | Returns a pointer to a host window. |
| CMFCDynamicLayout::GetMinSize | Returns the window size below which layout is not adjusted. |
| CMFCDynamicLayout::GetWindowRect | Retrieves the rectangle for the window's current client area. |
| CMFCDynamicLayout::HasItem | Checks if a child control was added to dynamic layout. |
| CMFCDynamicLayout::IsEmpty | Checks if a dynamic layout has no child windows added. |
| CMFCDynamicLayout::LoadResource | Reads the dynamic layout from AFX_DIALOG_LAYOUT resource and then applies the layout to the host window. |
| static CMFCDynamicLayout::MoveHorizontal | Gets a MoveSettings value that defines how much a child control is moved horizontally when the user resizes its hosting window. |
| static CMFCDynamicLayout::MoveHorizontalAndVertical | Gets a MoveSettings value that defines how much a child control is moved horizontally when the user resizes its hosting window. |
| static CMFCDynamicLayout::MoveNone | Gets a MoveSettings value that represents no motion, vertical or horizontal, for a child control. |
| static CMFCDynamicLayout::MoveVertical | Gets a MoveSettings value that defines how much a child control is moved vertically when the user resizes its hosting window. |
| CMFCDynamicLayout::SetMinSize | Sets the window size below which layout is not adjusted. |
| static CMFCDynamicLayout::SizeHorizontal | Gets a SizeSettings value that defines how much a child control is resized horizontally when the user resizes its hosting window. |
| static CMFCDynamicLayout::SizeHorizontalAndVertical | Gets a SizeSettings value that defines how much a child control is resized horizontally when the user resizes its hosting window. |
| static CMFCDynamicLayout::SizeNone | Gets a SizeSettings value that represents no change in size for a child control. |
| static CMFCDynamicLayout::SizeVertical | Gets a SizeSettings value that defines how much a child control is resized vertically when the user resizes its hosting window. |
| Name | Description |
|---|---|
| CMFCDynamicLayout::MoveSettings Structure | Encapsulates move data for controls in a dynamic layout. |
| CMFCDynamicLayout::SizeSettings Structure | Encapsulates size change data for controls in a dynamic layout. |
Header: afxlayout.h
Adds a child window, typically a control, to the list of windows that are controlled by the dynamic layout manager.
BOOL AddItem(
HWND hwnd,
MoveSettings moveSettings SizeSettings sizeSettings);
BOOL AddItem(
int nID,
MoveSettings moveSettings SizeSettings sizeSettings);
Parameters
hwnd
The handle to the window to add.
nID
The ID of the child control to add.
moveSettings
A structure that describes how the control should be moved as the window size changes.
sizeSettings
A structure that describes how the control should be resized as the window size changes.
Return Value
TRUE if the item was added successfully; otherwise FALSE.
Remarks
The position and size of a child control is changed dynamically when a hosting window is being resized.
Adds a child window, typically a control, to the list of windows that are controlled by the dynamic layout manager.
void Adjust();
Remarks
The position and size of a child control is changed dynamically when a hosting window is being resized.
Stores and validates the host window.
BOOL Create(CWnd* pHostWnd);
Parameters
pHostWnd
A pointer to the host window.
Return Value
TRUE if creation succeeded; otherwise FALSE.
Remarks
Returns a pointer to a host window.
CWnd* GetHostWnd();
Return Value
A pointer to the host window.
Remarks
By default all child control positions recalculated relative to this window.
Returns the window size below which layout is not adjusted.
CSize GetMinSize();
Return Value
The window size below which layout is not adjusted.
Remarks
The position and size of a child control is changed dynamically when a hosting window is being resized, but there is a minimum size below which the layout is not adjusted. The user can resize the window to a smaller size, but parts of the window are then hidden from view.
Retrieves the rectangle for the window's current client area.
void GetHostWndRect(CRect& rect,);
Parameters
rect
After the function returns, this parameter contains the bounding rectangle of the layout area. This is an out parameter; the input value is overwritten.
Remarks
Checks if a child control was added to dynamic layout.
BOOL HasItem(HWND hwnd);
Parameters
hwnd
The window handle for the control.
Return Value
TRUE if layout already has this item; otherwise FALSE.
Remarks
Checks if a dynamic layout has no child windows added.
BOOL IsEmpty();
Return Value
TRUE if layout has no items; otherwise FALSE.
Remarks
Reads the dynamic layout from AFX_DIALOG_LAYOUT resource and then applies the layout to the host window.
static BOOL LoadResource(CWnd* pHostWnd,
LPVOID lpResource,
DWORD dwSize);
Parameters
pHostWnd
A pointer to the host window.
lpResource
A pointer to the buffer that contains the AFX_DIALOG_LAYOUT resource.
dwSize
The buffer size in bytes.
Return Value
TRUE if resource is loaded and applied to the host window; otherwise FALSE.
Remarks
Gets a MoveSettings value that defines how much a child control is moved horizontally when the user resizes its hosting window.
static MoveSettings MoveHorizontal(int nRatio);
Parameters
nRatio
Defines as a percentage how far a child control is moved horizontally when the user resizes the host window.
Return Value
A MoveSettings value that encapsulates the requested move ratio.
Remarks
Gets a MoveSettings value that defines how much a child control is moved horizontally when the user resizes its hosting window.
static MoveSettings MoveHorizontalAndVertical(int nXRatio int nYRatio);
Parameters
nXRatio
Defines as a percentage how far a child control is moved horizontally when the user resizes the host window.
nYRatio
Defines as a percentage how far a child control is moved vertically when the user resizes the host window.
Return Value
A MoveSettings value that encapsulates the requested move ratio.
Remarks
Gets a MoveSettings value that represents no motion, vertical or horizontal, for a child control.
static MoveSettings MoveNone();
Return Value
A MoveSettings value that fixes the control in place, so that it does not move as the user resizes the host window.
Remarks
Encapsulates move data for controls in a dynamic layout.
struct CMFCDynamicLayout::MoveSettings;
Remarks
This is a nested class inside CMFCDynamicLayout.
Check if the move data specifies a nonzero horizontal move.
BOOL IsHorizontal() const
TRUE if the MoveSettings object specifies a nonzero horizontal move.
Check if the move data specifies no movement.
BOOL IsNone() const
TRUE if the MoveSettings object specifies no movement.
Check if the move data specifies a nonzero vertical movement.
BOOL IsVertical() const
TRUE if the MoveSettings object specifies a nonzero vertical movement.
Gets a MoveSettings value that defines how much a child control is moved vertically when the user resizes its hosting window.
static MoveSettings MoveVertical(int nRatio);
Parameters
nRatio
Defines as a percentage how far a child control is moved vertically when the user resizes the host window.
Return Value
A MoveSettings value that encapsulates the requested move ratio.
Remarks
Sets the window size below which layout is not adjusted.
void SetMinSize(const CSize& size);
Parameters
size
The desired size below which layout is not adjusted.
Remarks
The position and size of a child control is changed dynamically when a hosting window is being resized, but there is a minimum size below which the layout is not adjusted. The user can resize the window to a smaller size, but parts of the window are then hidden from view.
Gets a SizeSettings value that defines how much a child control is resized horizontally when the user resizes its hosting window.
static SizeSettings SizeHorizontal(int nRatio);
Parameters
nRatio
Defines as a percentage how far a child control is resized horizontally when the user resizes the host window.
Return Value
A SizeSettings value that encapsulates the requested size ratio.
Remarks
Gets a SizeSettings value that defines how much a child control is resized horizontally when the user resizes its hosting window.
static SizeSettings SizeHorizontalAndVertical(int nXRatio int nYRatio);
Parameters
nXRatio
Defines as a percentage how far a child control is resized horizontally when the user resizes the host window.
nYRatio
Defines as a percentage how far a child control is resized vertically when the user resizes the host window.
Return Value
A SizeSettings value that encapsulates the requested size ratio.
Remarks
Gets a SizeSettings value that represents no change in size for a child control.
static SizeSettings SizeNone();
Return Value
A SizeSettings value that fixes the control at a certain size, so that it does not change size as the user resizes the host window.
Remarks
Encapsulates size change data for controls in a dynamic layout.
struct CMFCDynamicLayout::SizeSettings;
Remarks
This is a nested class inside CMFCDynamicLayout.
Checks if the resize data specifies a nonzero horizontal resizing.
BOOL IsHorizontal() const
TRUE if the SizeSettings object specifies a nonzero horizontal resizing.
Checks if the resize data specifies no resizing.
BOOL IsNone() const
TRUE if the SizeSettings object specifies no resizing.
Checks if the resize data specifies a nonzero vertical resizing.
BOOL IsVertical() const
TRUE if the SizeSettings object specifies a nonzero vertical resizing.
Gets a SizeSettings value that defines how much a child control is resized vertically when the user resizes its hosting window.
static SizeSettings SizeVertical(int nRatio);
Parameters
nRatio
Defines as a percentage how far a child control is resized vertically when the user resizes the host window.
Return Value
A SizeSettings value that encapsulates the requested size ratio.