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

    • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

    • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today makes data protection a must-have, as we live in a data-driven society -- the digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join Seagate Cloud …

    Most Popular Programming Stories

    More for Developers

    Latest Developer Headlines

    RSS Feeds