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



    Comments

    • I have a problem adding a string to a CComboBox in the FormView

      Posted by Legacy on 02/04/2003 12:00am

      Originally posted by: Andrew

      Your article is very useful for me.It was successfull.
      But,when I try to add a string to a CComboBox in the FormView,the application terminated with error message.
      The message is like this

      -------------------------
      Debug Assertion Failed
      File:afxwin2.inl
      Line:735
      -------------------------

      Reply
    • I have a problem about TabCtrl and View

      Posted by Legacy on 04/17/2001 12:00am

      Originally posted by: kim

      Your article is very useful for me.
      Actually, I inserted ScrollView into TabCtrl.
      It was successfull.
      But,when I clicked on the ScrollView,the application terminated with error message.
      The message is like this
      -------------------------
      Debug Assertion Failed
      File:viewcore.cpp
      Line:252
      -------------------------

      I wrote VC++ code just as you did.
      I used ScrollView instead of FormView.

      What is the problem?
      Please advise me!


      Reply
    • Small Correction

      Posted by Legacy on 02/11/2001 12:00am

      Originally posted by: Vivek Rajan

      Good article -


      In the PostNcDestroy method :-

      Instead of commenting out CFormView::PostNcDestroy,
      you should call CWnd::PostNcDestroy directly.

      ( For more info on PostNcDestroy, see MSDN TN17 )

      Later-
      Vivek

      Reply
    • Simple, yet Great... Idea

      Posted by Legacy on 01/21/2000 12:00am

      Originally posted by: Achalla Srinivasu

      Hi,

      the idea is very good and helpful.

      Thank You....

      Regards,
      Srinivasu. A


      Reply
    • How to make docking pages

      Posted by Legacy on 09/15/1999 12:00am

      Originally posted by: Nemo

      I think your idea is a clue to my problem, but I cannot find the way. I need to implement docking pages like it is done in Delphi environment. I.e. I want to allow pages to be dragged away as floating window and stick back to sheet if they are dragged over it. Can you give me advise?

      Sincerely,
      Serge.

      Reply
    • Thanks, exactly what I needed

      Posted by Legacy on 02/15/1999 12:00am

      Originally posted by: chris Rau

      I am new to MFC and was trying to figure out this exact issue when I found your post. Thank you very much. It works like a charm.

      Reply
    • It's work Ok, but not correctly...

      Posted by Legacy on 02/02/1999 12:00am

      Originally posted by: Aleks

      It's work Ok, but not correctly:

      In ideal, if I navigate to controls using TAB key, focused control
      must begin visiable in property page (i.e. Veiw automatically scrolled
      to focused control position). Next, if I already in this page, I can't
      navigate to other pages and Prop Sheet's buttons, using navigation keys.

      Best way to solve this problem - take original CFormView and CScrollView
      source code, remove all non-needed (on CDocument links and so on), replace
      CView to CWnd, GetParentFrame() to GetParent(),correct some errors and
      add navigation key press and othe messages handling. I hope it's will
      be fine!

      Aleks

      Reply
    Leave a Comment
    • Your email address will not be published. All fields are required.

    Top White Papers and Webcasts

    • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

    • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

    Most Popular Programming Stories

    More for Developers

    RSS Feeds