|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
CResizableSheet(Ex) and CResizablePage(Ex)These four classes handle resizable property sheets, wizards and the wizard 97 style dialogs, and are now fully based on my ResizableLib class library (see article). The user will have the ability to resize the dialog, with consequent rearrangement of child windows. You can control the minimum and maximum size allowed, as well as the maximized size and position of the dialog. The size grip is displayed by default, but you may turn it off. Automatic Save/Restore the dialog's size and position, along with the active page, is also supported. Conversion of a previously existant property sheet or wizard should be very simple. I will talk about non-Ex classes for the rest of the article, but the same concepts applies for Wizard 97 dialogs. The Sample ApplicationsThis is a view of the sample dialog at minimum size as a property sheet and in wizard mode:
Note that the minimum width is not the default. You may see how to do this in the next section. This is a screenshot of the resizable version of Wizard97 sample project coming with Visual C++.
Usage - Step by StepAdd the ResizableLib to your project's workspace, as explained in the relative article. Create a property sheet or wizard dialog and do the relative associations with MFC classes, for example using the Property Sheet component, or take one you have already made which you want to be resizable. You don't need to change any window style to have the dialog resizing. Include 'ResizableSheet.h' in the property sheet associated header file. Search and replace all Include 'ResizablePage.h' in the property pages associated header file. Search and replace all The same applies for wizard dialogs, of course. Your property sheet header file should appear like this: // MyPropertySheet.h : header file // #include "MyPropertyPages.h" ///////////////////////////////////////////////////////////////////////////// // CMyPropertySheet #include "ResizableSheet.h" class CMyPropertySheet : public CResizableSheet { DECLARE_DYNAMIC(CMyPropertySheet) // Construction public: CMyPropertySheet(CWnd* pWndParent = NULL); // ( other stuff ) // ... } In your BOOL CMyPropertySheet::OnInitDialog()
{
CResizableSheet::OnInitDialog();
// set minimal size
CRect rc;
GetWindowRect(&rc);
SetMinTrackSize(CSize(GetMinWidth(), rc.Height()));
// enable save/restore, with active page
EnableSaveRestore(_T("Properties"), TRUE, TRUE);
return TRUE;
}
Your property pages header file should appear like this: // MyPropertyPages.h : header file // ///////////////////////////////////////////////////////////////////////////// // CMyPropertyPage1 dialog #include "ResizablePage.h" class CMyPropertyPage1 : public CResizablePage { DECLARE_DYNCREATE(CMyPropertyPage1) // ... } // and so on for the other pages ... In each page's BOOL CMyPropertyPage2::OnInitDialog()
{
CResizablePage::OnInitDialog();
// preset layout
AddAnchor(IDC_LIST1, TOP_LEFT, CSize(50,70));
AddAnchor(IDC_PICTURE1, CSize(50,0), CSize(100,70));
AddAnchor(IDC_GROUP1, CSize(0,70), BOTTOM_RIGHT);
AddAnchor(IDC_CHECK1, CSize(0,85));
AddAnchor(IDC_RADIO1, CSize(100,85));
AddAnchor(IDC_COMBO1, CSize(100,70));
AddAnchor(IDC_BUTTON1, BOTTOM_RIGHT);
m_ctlEdit1.AddString(_T("Just a single item to test the "
"listbox behavior with very long lines..."));
m_ctlEdit1.SetHorizontalExtent(300);
return TRUE;
}
You are ready to rebuild your project and you will have a resizable property sheet or a wizard dialog just as you wanted. For further details, see the next section. Class ReferenceThe property sheet class inherits from CResizableLayout, CResizableGrip, CResizableMinMax, CResizableState and obviously from CPropertySheet.
The property page class inherits from CResizableLayout and obviously from CPropertyPage. The other classes are not needed.
CResizableSheet::CResizableSheetCResizableSheet() CResizableSheet(UINT nIDTemplate, CWnd* pParentWnd = NULL) CResizableSheet(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL) CResizablePage::CResizablePageCResizablePage() CResizablePage(UINT nIDTemplate, CWnd* pParentWnd = NULL) CResizablePAge(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL)
CResizableSheet::EnableSaveRestorevoid EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly, BOOL bWithPage = FALSE)
CResizable???::???
Member functions to set/reset maximized size and position may seem rather useless, since you don't have a maximize box in the window's caption. I left them because I think it should be possible to enable caption buttons, playing a little with window's styles. ConclusionI hope these classes can make some programmers' life a little easier. I also want to thank Jerzy Kaczorowski for his unique support during the port of Integration with The CVS tree is now on Source Forge. Updates28 Jul 2000
27 Oct 2000
13 Mar 2001
11 Jun 2001
15 Jul 2001
28 Oct 2001
|
||||||||||||||||||||||