Inserting a CFormView into a CPropertySheet

In many cases, is usefull to have in one page of propery sheet more controls. But if the area of page is not enough, you have to insert some scroll bars into page. To make this simple you can do the followings:

Creating one CFormView

  • Generate a new dialog with Child style, which contains all controls from one scrollable page on resource
  • From class wizard add a new CFormView, with ID be the id of created dialog. (CMyFormView)
  • Make the constuctor and destructor to be public (by default, these are protected for dynmicaly creation) (CMyFormView)
  • From classwizard, add in this class (CFormView) a new member PostNcDestroy.
  • From the generated body function remove CFormView::PostNcDestroy() ( In CFormView::PostNcDestroy is called delete this)
  • Add handler for WM_CREATE message into CMyFormView, and in the body of the generated function call SetScrollSizes(MM_TEXT, CSize(100,200));
  • Add a new function public: virtual BOOL CMyFormView::Create(CWnd* pParent), with body

  • BOOL CMyFormView::Create(CWnd *pParent)
    {
    CRect rect; pParent->GetClientRect(rect);
    return CFormView::Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, pParent, 0, NULL);
    }

    Adding the new member of CMyFormView type to one of CPropertyPage

  • From classwizard and in one of pages’s sheet, a new member of CMyFormView type.
  • For this page add handler for WM_INITDIALOG message.
  • In the body call, Create(this) of member of CMyFormView type
  • If something is missing or wrong, feel free to ask me at: mihai_f@hotmail.com

    More by Author

    Get the Free Newsletter!

    Subscribe to Developer Insider for top news, trends & analysis

    Must Read