CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    Join Date
    Jun 2004
    Posts
    1,352

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ovidiucucu View Post
    It's not very clear what exactly you want to accomplish, so please clarfy the points below:
    1. you want a property sheet which is is in wizard mode or not?
    2. you want a property sheet which is child or is owned by a (form) view?
    3. what exactly this mean?

    To see the difference between child and owned, take a look at these FAQs:


    Anyhow, the initial idea of using a tab control to switch between viwes or to show/hide different sets of controls is not so good.
    Using the property sheet is easier and more elegant.
    Ok

    What I want to do is have a Formview where I can have the functionality of a CTabCtrl. The functionality I'm looking for is to be able to access controls in a designated area, and also manipulate controls in the remaining client area. Property PAGES in a PropertySheet doesn't offer that capability: At least I don't see how to make a PropertySheet( the object that contains the PropertyPages) a Child of a FormView.

    I see the that:

    CPropertySheet::Create

    BOOL Create( CWnd* pParentWnd = NULL, DWORD dwStyle = WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_VISIBLE, DWORD dwExStyle = WS_EX_DLGMODALFRAME );



    But I don't see how to set the position coordinates of the CPropertySheet.
    Rate this post if it helped you.

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

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    But I don't see how to set the position coordinates of the CPropertySheet.
    Don't you know CWnd::MoveWindow exists?
    Victor Nijegorodov

  3. #18
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    I'm not sure if you are talking about CPropertySheet or CPropertyPage.

    There is no way I can see of as setting CPropertySheet to wizard mode as there is no control for it.


    Still don't see how you position the the PropertyPage. ... all I get is a popup centered on the screen.
    You may create a class derived from CPropertySheet. The constructor of the class will either take an ID for the string caption to be used or a const char* for the caption itself. The CPropertySheet isn't a dialog but actually (only) a customized tab control (window) with basic functions to take and manage dialog pages.

    Each dialog page can be created with the resource editor and should be a child window (no menu, no frame) and not a popup. Then you need to add each page to the property sheet calling the AddPage member.

    If you have some dialog controls common to each page, you might think of using a class derived from CDialog (or CFormView) rather than from CPropertySheet. This form may have any number of controls and a (big) tab control which is supposed to take and handle the property pages. If you do so, you would need to add functions like AddPage, RemovePage, GetActivePage and so on yourself, what isn't much difficult cause you could get most implementations from the MFC source dlgprop.cpp.

  4. #19
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    how to make a PropertySheet( the object that contains the PropertyPages) a Child of a FormView.
    This way
    Code:
    int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
       if (CFormView::OnCreate(lpCreateStruct) == -1)
          return -1;
    
       m_pps = new CMyPropertySheet(_T("My Propery Sheet"));
       // create child property sheet
       m_pps->Create(this, WS_CHILD|WS_VISIBLE);
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #20
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by itsmeandnobodyelse View Post
    CPropertySheet isn't a dialog but actually (only) a customized tab control (window) with basic functions to take and manage dialog pages.
    Although CPropertySheet isn't drived from CDialog, a property sheet IS a dialog (of window class #32770). In fact it's a kind of complex Windows control having a dialog as a layer for a tab control (if not in wizard mode), some buttons and several other dialogs (pages).

    Quote Originally Posted by itsmeandnobodyelse View Post
    ...you might think of using a class derived from CDialog (or CFormView) rather than from CPropertySheet. This form may have any number of controls and a (big) tab control which is supposed to take and handle the property pages. If you do so, you would need to add functions like AddPage, RemovePage, GetActivePage and so on yourself, what isn't much difficult cause you could get most implementations from the MFC source dlgprop.cpp
    It's like reinventing the wheel. I made it once myself, but it's not a good choice.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  6. #21
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Function to Draw Controls from a different dialog box template

    To understand better what property sheets are, you can take a look in MSDN at Property Sheet topics.
    The MFC classes CPropertySheet and CPropertyPage, just encapsulate the WinAPI stuff presented there.

    An also you can take a look at this article: http://www.codexpert.ro/articole.php?id=11
    It is in Romanian, but the pictures are self-explanatory.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  7. #22
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ovidiucucu View Post
    Although CPropertySheet isn't drived from CDialog, a property sheet IS a dialog (of window class #32770). In fact it's a kind of complex Windows control having a dialog as a layer for a tab control (if not in wizard mode), some buttons and several other dialogs (pages).


    It's like reinventing the wheel. I made it once myself, but it's not a good choice.
    You can't seed it with a dialog resource, so all the internal properties are of no value - beside you are content with the functionality of a tabcontrol which can manage dialog pages.

    'Reinventing the wheel' would at least mean there is a wheel. But the CPropertySheet has only a poor interface and was not able to 'roll' a normal dialog.

    I often used a own property sheet dialog form and there is no easy alternative in MFC if you want to run a main dialog form together with tabbed subforms where all forms were designable using the resource editor.

  8. #23
    Join Date
    Jun 2004
    Posts
    1,352

    Re: Function to Draw Controls from a different dialog box template

    Well I've tried the following and I can't get it to pop up.The App runs but it doesn't show anything.

    If I set it to modal it works and also the the wizard mode works


    Code:
    	::CPropertySheet nameSheet( "Hobby List",this);
    
    
    	CNamePage  pgName;
    	CHobbyPage pgHobby; 
    
    	nameSheet.AddPage(&pgName);
    	nameSheet.AddPage(&pgHobby); 
    
    
    	//nameSheet.SetWizardMode();  //works 
    
    
    	//nameSheet.DoModal();     //works, but I don't want modal
    
    		nameSheet.Create(this,  WS_CHILD | WS_CAPTION | WS_VISIBLE); 
    		nameSheet.SetWindowPos(this,0,0,100,100,SWP_SHOWWINDOW);
    
    
    	nameSheet.ShowWindow(SW_SHOW);
    Rate this post if it helped you.

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

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    Well I've tried the following and I can't get it to pop up.The App runs but it doesn't show anything.

    If I set it to modal it works and also the the wizard mode works


    Code:
    	::CPropertySheet nameSheet( "Hobby List",this);
    
    
    	CNamePage  pgName;
    	CHobbyPage pgHobby; 
    
    	nameSheet.AddPage(&pgName);
    	nameSheet.AddPage(&pgHobby); 
    
    
    	//nameSheet.SetWizardMode();  //works 
    
    
    	//nameSheet.DoModal();     //works, but I don't want modal
    
    		nameSheet.Create(this,  WS_CHILD | WS_CAPTION | WS_VISIBLE); 
    		nameSheet.SetWindowPos(this,0,0,100,100,SWP_SHOWWINDOW);
    
    
    	nameSheet.ShowWindow(SW_SHOW);
    And where was this code placed?
    And how and when is is called?

    Isn't this CPropertySheet nameSheet a local variable in some block?
    Victor Nijegorodov

  10. #25
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    Well I've tried the following and I can't get it to pop up.The App runs but it doesn't show anything.

    If I set it to modal it works and also the the wizard mode works


    Code:
    	::CPropertySheet nameSheet( "Hobby List",this);
    
    
    	CNamePage  pgName;
    	CHobbyPage pgHobby; 
    
    	nameSheet.AddPage(&pgName);
    	nameSheet.AddPage(&pgHobby); 
    
    
    	//nameSheet.SetWizardMode();  //works 
    
    
    	//nameSheet.DoModal();     //works, but I don't want modal
    
    		nameSheet.Create(this,  WS_CHILD | WS_CAPTION | WS_VISIBLE); 
    		nameSheet.SetWindowPos(this,0,0,100,100,SWP_SHOWWINDOW);
    
    
    	nameSheet.ShowWindow(SW_SHOW);
    It isn't going to work because the nameSheet will go out of scope. You'll need to create a m_NameSheet variable as part of the CFormView derived class and call the Create method in OnInitialUpdate.

  11. #26
    Join Date
    Jun 2004
    Posts
    1,352

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by Arjay View Post
    It isn't going to work because the nameSheet will go out of scope. You'll need to create a m_NameSheet variable as part of the CFormView derived class and call the Create method in OnInitialUpdate.
    Ok, I got it to work.

    Did all the initialization in the OnInitialize of the Formview.

    Calling SetPosWindow causes an assertion error. Have to look into that.


    I also found that doing Modless Dialog Boxes gives me the functionality I'm looking for.
    Rate this post if it helped you.

  12. #27
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    Did all the initialization in the OnInitialize of the Formview.
    What is OnInitialize? Do you mean OnInitialUpdate?

    I also found that doing Modless Dialog Boxes gives me the functionality I'm looking for.[/QUOTE]Yes, that is what we told you to do - calling Create( ) on a CPropertySheet creates a modeless property sheet.

  13. #28
    Join Date
    Jun 2004
    Posts
    1,352

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by Arjay View Post
    What is OnInitialize? Do you mean OnInitialUpdate?

    I also found that doing Modless Dialog Boxes gives me the functionality I'm looking for.
    Yes, that is what we told you to do - calling Create( ) on a CPropertySheet creates a modeless property sheet.[/QUOTE]


    That is another way to do it. However, I find it's about the same amount of work as a doing a CTabCtrl. The CTabCtrl also has some nice features as to changing the position of the tabs.

    I find the easiest way is to do Modless Dialogs and pass them a pointer to the parent window (so as to manipulate the parents controls, ... the functionality I was looking for) and add the templates as you go along and or as you want to increase proccessing of the parent class( It's better than mount controls on top each other and hiding them, like some else suggested). ... Kind of like a split view with Dialog boxes and a Formview.

    Another cool thing about doing the modless dialogs and passing it a pointer to the FormView is that you can make the Modless Dialogs take up the whole area of the Formview and somewhat make it multiview(.. if you don't want to create a View for each screen and go that route.

    Thanks for the help, It's always cool to have several ways to do stuff. You never know what situation will come up.
    Last edited by ADSOFT; September 14th, 2010 at 09:31 PM.
    Rate this post if it helped you.

  14. #29
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by ADSOFT View Post
    That is another way to do it. However, I find it's about the same amount of work as a doing a CTabCtrl. The CTabCtrl also has some nice features as to changing the position of the tabs.
    Do you think we should mention all the possible ways to something? We've got 29 replies now to get you to this point, would you have gotten to this point sooner if we had suggest several alternatives?

    Quote Originally Posted by ADSOFT View Post
    I find the easiest way is to do Modless Dialogs and pass them a pointer to the parent window (so as to manipulate the parents controls,
    That's another approach to take but it introduces tight coupling between UI components. If you follow any of the recent design patterns, you'd know that it isn't recommended that one UI component manipulate the controls of another UI component.

    Quote Originally Posted by ADSOFT View Post
    Another cool thing about doing the modless dialogs and passing it a pointer to the FormView is that you can make the Modless Dialogs take up the whole area of the Formview and somewhat
    If you want the property pages to actually be a child control of the formview, use the approach I suggested. If you want the prop sheet to be separate, then use a modeless sheet.

    It would help if you figured out what you want before asking questions; otherwise, you're wasting the forum's time.

  15. #30
    Join Date
    Jun 2004
    Posts
    1,352

    Re: Function to Draw Controls from a different dialog box template

    Quote Originally Posted by Arjay View Post

    It would help if you figured out what you want before asking questions; otherwise, you're wasting the forum's time.

    Well what I wanted was a function to use a dialog template to utilize it's componts. The answer is

    Code:
    myDialog.Create(IDD_MyDialog); 
    
    After creating myDialog in classwizard from IDD_MyDialog

    I took alot of time to write the title of my question.

    It's an open forum, and if it took 29 responses to get the answer of my question, it wasn't a waste of time.
    Rate this post if it helped you.

Page 2 of 3 FirstFirst 123 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