CResizer Class |
Description
The CResizer class can be used to automatically rearrange the position of child windows when the parent window is resized. Typically this is used to reposition the controls for a dialog.
CResizer Members
CResizer | CResizer();Constructor for the CResizer. |
virtual void AddChild(CWnd* pWnd, Alignment corner, DWORD dwStyle);
virtual void AddChild(HWND hWnd, Alignment corner, DWORD dwStyle);Adds a child window to be managed by the CResizer.
CRect GetMinRect() const;Returns the minimum allowed rectangle.
CRect GetMaxRect() const;Returns the maximum allowed rectangle.
virtual void HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);Performs the resizing and scrolling. Call this function from within the window's DialogProc.
virtual void Initialize(CWnd* pParent, RECT rcMin, RECT rcMax = CRect(0,0,0,0));Specifies the parent window, as well as its minimum and maximum size.
virtual void RecalcLayout();Repositions the child windows.
Remarks
To use the CResizer class to manage the position of child windows, perform the following steps.
- Use Initialize to specify the parent window, along with the minimum and maximum permitted sizes.
- Use AddChild for each child window we wish to manage.
- Call HandleMessage from within DialogProc or WndProc to pass messages on to CResizer
The following code demonstrates how to initialize CResizer for a dialog.
BOOL CMyDialog::OnInitDialog() { // Perform other tasks ... // Initialize dialog resizing m_Resizer.Initialize( this, CRect(0, 0, 300, 200) ); m_Resizer.AddChild(m_RadioA, topleft, 0); m_Resizer.AddChild(m_RadioB, topleft, 0); m_Resizer.AddChild(m_RadioC, topleft, 0); m_Resizer.AddChild(m_Button, topleft, 0); m_Resizer.AddChild(m_CheckA, bottomright, 0); m_Resizer.AddChild(m_CheckB, bottomright, 0); m_Resizer.AddChild(m_CheckC, bottomright, 0); m_Resizer.AddChild(m_RichEdit1, topright, RD_STRETCH_WIDTH); m_Resizer.AddChild(m_RichEdit2, bottomleft, RD_STRETCH_WIDTH| RD_STRETCH_HEIGHT); return true; }
The following code shows how to add the CResizer message handling.
INT_PTR CMyDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { // Pass resizing messages on to the resizer m_Resizer.HandleMessage(uMsg, wParam, lParam); // switch (uMsg) // { // Additional messages to be handled go here // } // Pass unhandled messages on to parent DialogProc return DialogProcDefault(uMsg, wParam, lParam); }
Summary Information
Header file | dialog.h |
Win32/64 support | Yes |
WinCE support | Yes |