CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Join Date
    Sep 2010
    Posts
    11

    MFC Feature Pack - How to create CMFCPropertySheet control?

    Hello.

    I'm working on a project that uses the MFC Framework to create the GUI. More specifically, the so-called "Feature Pack" of MFC is used. As I haven't used the MFC Framework until now, I currently try to understand the basics. So I read a few tutorials and I think the "CMFCPropertySheet" control would be what I need. So created a new "empty" MFC project in Visual Studio and now I try add a CMFCPropertySheet control to the main window. Later I will add the Pages, but first I need to add the control.

    What I have done so far is deriving my own Class "CMyPropSheet" from "CMFCProperty" sheet. I also added a method OnCreate() to my own class, which I think is the correct place to create and add the Sheets later. But now, how the heck do I create an instance of my CMPropSheet and add it to my main window? I think I must do this inside the OnCreate() method of the "MainFrm" class. Is that correct? If so, what is correct method to call? Create or CreateEx and what parameters do I need to pass? I couldn't find any example on this.

    What I tried is:
    Code:
    s

  2. #2
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Sorry, I mistakenly hit the "Submit" button too early ^^

    Another try, what I tried is:
    Code:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	[...]
    
    	//Create the Properties Sheet
    	if(!m_wndPropSheet.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP))
    	{
    		TRACE0("Failed to create toolbar\n");
    		return -1;      // fail to create
    	}
    
    	[...]
    }
    But the result now is "Failed to create empty document" on startup of the application

    Can anybody point me to the right direction? What am I doing wrong?

    Thanks in advance!

    Regards,
    Daniel.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Debug your code, step into the
    Code:
    if(!m_wndPropSheet.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP))
    and try to understand what was wrong and why...
    Victor Nijegorodov

  4. #4
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    wont propertysheet/propertypage be created on a dialog or some framewnd....
    rather than the MainFrame itself ?? correct me if I am wrong..

  5. #5
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Quote Originally Posted by vcdebugger View Post
    wont propertysheet/propertypage be created on a dialog or some framewnd....
    rather than the MainFrame itself ?? correct me if I am wrong..
    Thank you for reply!

    Can you elaborate a bit on this? I would like to have the PorpertySheet inside my main window, filling the space between the menubar on the top and the statusbar on the bottom. Is that possible at all? If yes, can you give me some hint how I would do this with the help of a "dialog" or a "framewnd"? If it's not possible, what would be an alternative? Actually all I need is some widget that I can place in the main window and which provides several pages with tabs. Once I have achieved that, the next step will be to arrange the "DockablePanes", which already exist in the project, in their appropriate pages. Currently all those DockablePanes are floating around in the main window, which is rather confusing for the user. So we are trying to get them distributed over several tabs.

    (BTW: I managed to "merge" several DockablePanes into a TabbesPane, but then each DockablePane had it's own Tab. I need two or three DockablePanes to be arrange inside the same Tab/Page)
    Last edited by dtrick; September 29th, 2010 at 05:36 AM.

  6. #6
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Quote Originally Posted by VictorN View Post
    Debug your code, step into the
    Code:
    if(!m_wndPropSheet.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP))
    and try to understand what was wrong and why...
    Okay, I will try to do so later this day. Do you think Create() is the correct function to create the control? And are the flags appropriate?

    I couldn't find any information on which flags the PropertySheet control expects in its Create() function.

    Somewhere I read that with the "Feature Pack" I am supposed to use CreateEx() instead of Create(), but the CreateEx() function had even more parameters for which I couldn't find any documentation specific to PropertySheet...

    Any information on this would be greatly appreciated...
    Last edited by dtrick; September 29th, 2010 at 05:34 AM.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Which CreateEx do you mean?
    CMFCPropertySheet Class has neither its own [B]Create [/Bnor CreateEx ]method.
    CPropertySheet class from which CMFCPropertySheet is derived does have Create, but not CreateEx method.
    Victor Nijegorodov

  8. #8
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Quote Originally Posted by VictorN View Post
    Which CreateEx do you mean?
    CMFCPropertySheet Class has neither its own [B]Create [/Bnor CreateEx ]method.
    CPropertySheet class from which CMFCPropertySheet is derived does have Create, but not CreateEx method.
    Yeah, I noticed that too, and actually I don't know which one I am supposed to use. In my project the controls (e.g. DockablePane) are created via Create() before they are added to the main window. And this apparently does work. Now, in some "Feature Pack" tutorial I read that with new controls from the Feature Pack I'm supposed to use the CreateEx() function instead of Create(). However I'm not sure if that applies to the PropertiesSheet as well. So can you give me any hint on how to find out what is the correct method to create an instance of CMDPropertySheet, so I can add that new instance to my main window? I looked at the "New Controls" example that ships with the Feature Pack. In that example they use the PropertySheet, but it seems the way they instantiated it is quite different from my project. They used DoModal() on the ProperySheet instead of showing the main window. In my project, I already have a main window with various controls inside, and I need to put the PropertySheet inside the main window too! If that is not possible for some reason, I need an alternative to PropertySheet. Suggestions are very welcome! Or if I need further controls (vcdebugger mentioned "dialog or some framewnd") to put the Property Sheet in the main window, it would be great if you could point me to the right one...
    Last edited by dtrick; September 29th, 2010 at 06:42 AM.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Quote Originally Posted by dtrick View Post
    ... Now, in some "Feature Pack" tutorial I read that with new controls from the Feature Pack I'm supposed to use the CreateEx() function instead of Create(). However I'm not sure if that applies to the PropertiesSheet as well. So can you give me any hint on how to find out what is the correct method to create an instance of CMDPropertySheet, ...
    1. In *what* "Feature Pack" tutorials did you read about CreateEx() and for *which* controls?
    2. I already gave you a hint to MSDN. What could be more "correct" than MSDN?
    Victor Nijegorodov

  10. #10
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    (1) Sorry, I cannot find the paragraph right now. Maybe I was mistaken there. So you are saying creating an instance of CMFCPropertySheet via Create() would be the correct method for MFC? Please remember that I'm new to MFC and I see they sometimes use Create() and sometimes they use CreateEx() to create instances of controls. I haven't yet figured out what the difference is and when I need to use which one. Any hint on this would be helpful.

    (2) Well, yes. The MSDN documentation specifies the function and their parameters. Still I don't have a clue whether I'm supposed to used that function for what I try to achieve or not. The documentations says about CPropertySheet::Create "Displays a modeless property sheet". What exactly does mode-less mean in this context? Moreover I want to add the control into my main window. Does Create() create the control in a way that I can use it to add it to main window? Also, as a MFC beginner, I'm pretty confused on all those Style and ExStyle flags. There is a long list about which flags exist. But which ones do I need for what I'm trying to achieve? Would the "defaults", -1 and 0, respectively, be okay?

    Furthermore: I'm not sure whether CMFCPropertySheet can what I want. It just looked "suitable" to me in the tutorial at a first glance. Any suggestions on a more suitable would be much appreciated!
    Last edited by dtrick; September 29th, 2010 at 07:16 AM.

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    To see what the modeless property sheet is - just implement the code shown in MSDN article CPropertySheet::Create

    About modal/modeless dialogs - see MSDN

    If you'd like, however, to place your propertysheet on some dialog template inside mane frame - then create a MFC SDI project with the CFormView derived class as a View, then in the created CFormView derived class method OnInitialUpdate add your code:
    Code:
    int void C<SomeViewName>::OnInitialUpdate()
    {
    	CFormView::OnInitialUpdate();
    
    	//Create the Properties Sheet
    	if(!m_wndPropSheet.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP))
    	{
    		TRACE0("Failed to create toolbar\n");
    		return -1;      // fail to create
    	}
    
    	[...]
    }
    Victor Nijegorodov

  12. #12
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Okay, thanks!

    But since I am working in an existing project, creating a new project is not an option for me. So is it possible to add that so-called "dialog template" to an existing project afterwards? If so and if I understand you correctly, I would create a custom class that is derived from CFormView. Inside that class I create the CPropertySheet. And finally I can my CFormView-derived class to the main window? Please correct me, if I'm wrong...

  13. #13
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Since you are "new to MFC" I'd suggest to do your tests/trials in some other test projects. Then, if you will see that your test is successful - move it to your main project.

    Besides:
    1. Controls are usually placed not in a main frame window but in some dialog or View having dialog template.
    2. You didn't mention what type of MFC project you you are working with.
    Victor Nijegorodov

  14. #14
    Join Date
    Sep 2010
    Posts
    11

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Okay, I followed your suggestion and created a new "Test" project.

    I created an "MFC Application" with "Single Document" type and "MFC Standard" style. I also changed the BaseClass of the View to CFormView. I think that is what you ment. I added m_wndPropSheet as a member to CFMCTest4View as a CPropertySheet. Then in the OnInitialUpdate() method of the CFormView-derived class I added the follwoing code:

    Code:
    void CMFCTest4View::OnInitialUpdate()
    {
        CFormView::OnInitialUpdate();
        
        //Create the Properties Sheet
        if(!m_wndPropSheet.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP))
        {
            TRACE0("Failed to create toolbar\n");
            //return -1;      // fail to create           <-- can't return anything here
        }
    
        GetParentFrame()->RecalcLayout();
        ResizeParentToFit();
    }
    The result looks like this:
    http://img291.imageshack.us/img291/7594/mfctest.png

    Now can you please tell me how I can manage the make the PropertySheet actaully appear in the are where the "TODO" text is currently displayed?

    Moreover, how would I kick out the clunky "Ribbons" bar, if I don't need it?

    (BTW: In my actual project, the MainFrm is a CFrameWnd, the View is a CView and the "main" class is a CWinAppEx, if that matters)

    Thanks,
    Daniel.
    Last edited by dtrick; September 29th, 2010 at 11:37 AM.

  15. #15
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Feature Pack - How to create CMFCPropertySheet control?

    Quote Originally Posted by dtrick View Post
    Please, next time attach images to your post.

    Quote Originally Posted by dtrick View Post
    Now can you please tell me how I can manage the make the PropertySheet actaully appear in the are where the "TODO" text is currently displayed?
    Use CWnd::MoveWindow to move your sheet to a new position.
    To know position of "TODO"control - use GetWindowRect (note, that control ID must be changed from IDC_STATIC to something else)
    Quote Originally Posted by dtrick View Post
    TMoreover, how would I kick out the clunky "Ribbons" bar, if I don't need it?
    I don't know. I hate the most of new "themed" and Ribbons" features and don't use them at all.
    Victor Nijegorodov

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured