CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Join Date
    Aug 2009
    Posts
    84

    [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Hello everyone!!!!

    I have a nested propertysheets (on some propertypages I have another propertysheet with pages itself). I have also a XML file of general settings that I read in OnInitDialog()'s form event.
    Some pages of this nested propertysheets have settings that depends from other pages and of general settings from xml file. Like if I activate a checkbox in a page I change in the xml file the related value from 0 to 1 and in the same time I enable the controls in another page.
    I know there's a way to communicate between propertypages from the top (the dialog form) so it can share also xml file object maybe using DoDataExchange to reduce complexity.
    But how I can do that?... I tried to read the help of MSDN but it's like messing me a bit so I'm here asking you...

    Thanks to all.
    Ciao
    Luigi

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Have a look at this discussion
    Victor Nijegorodov

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Here's a similar concept of using a 'document' in a property sheet:

    http://www.codeguru.com/forum/showth...=442853&page=2

  4. #4
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Quote Originally Posted by Arjay View Post
    Here's a similar concept of using a 'document' in a property sheet:

    http://www.codeguru.com/forum/showth...=442853&page=2
    Hello arjay,

    I find your methodology interesting and also elegant.... document and view....
    Just three little questions:

    1) Since as dialog, I'm using a dialog resource where I add a menu, coding like this:

    CPropSheet Sheet(_T("Main Sheet"));

    would assume there's a m_pMainWnd variable to pass &Sheet. In this case I have m_hWnd since it's a dialog resource...how I can "put" the sheet on it?.

    2) Are there attributes to tell the sheet I don't want those buttons at bottom (Ok, Cancel, Apply, ?)?

    3) If I have nested sheets, shall I have maybe to pass to deeper views also the top sheet pointer?... I mean, if I have at top sheet this:

    AddPage(&FirstTopTab_View);

    in the OnInitDialog() of FirstTopTab_View when I code:

    CSecondLevelSheet SecondLevelSheet(_T("Second Level Sheet"));

    for the Page of that SecondLevelSheet I shall pass also the pointer of topsheet like:

    AddPage(&SecondLevelFirstTab_View(Sheet));

    so in the ctor of SecondLevelFirstTab_View I can have something like:

    CSecondLevelFirstTab_View::CSecondLevelFirstTab_View(CPropSheet* mainsheet, CSecondLevelSheet* parentsheet);

    right?... Or doesn't it need?

    Thanks
    ciao
    Luigi

  5. #5
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Uhm.... no clue?... :-)

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Quote Originally Posted by npuleio View Post
    1) Since as dialog, I'm using a dialog resource where I add a menu, coding like this:
    Code:
           CPropSheet Sheet(_T("Main Sheet"));
    would assume there's a m_pMainWnd variable to pass &Sheet. In this case I have m_hWnd since it's a dialog resource...how I can "put" the sheet on it?.

    2) Are there attributes to tell the sheet I don't want those buttons at bottom (Ok, Cancel, Apply, ?)?
    1) I don't see anything that looks like a "menu" in the "code snippet" you have posted.

    2) These buttons have control IDs: IDOK, IDCANCEL, ID_APPLY_NOW. So you won't have any problem to hide the controls with those IDs.
    Additional info you could find in:
    HOWTO: How to Change Default Button on CPropertySheet
    HOWTO: How to Hide the Apply Button in CPropertySheet
    How To Create a Modeless CPropertySheet with Standard Buttons
    Victor Nijegorodov

  7. #7
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Hello VictorN,

    1) I mean I call the propertysheet from a CDialog window because on this CDialog I put a menu...and since the dialog isn't a CWinApp I can't do like this:

    CPropSheet sheet( _T("This is a property sheet") );
    m_pMainWnd = &sheet;
    INT_PTR nResponse = sheet.DoModal();

    because CDialog doesn't have m_pMainWnd....so I have to put the propertysheet in the "content" of CDialog otherwise it would appear as two separate windows...

    2) doesn't exists any PSH_NOblahblah flag to hide IDOK, IDCANCEL and IDHELP like that PSH_NOAPPLYNOW?...

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Quote Originally Posted by npuleio View Post
    Hello VictorN,

    1) I mean I call the propertysheet from a CDialog window because on this CDialog I put a menu...and since the dialog isn't a CWinApp I can't do like this:

    CPropSheet sheet( _T("This is a property sheet") );
    m_pMainWnd = &sheet;
    INT_PTR nResponse = sheet.DoModal();

    because CDialog doesn't have m_pMainWnd....so I have to put the propertysheet in the "content" of CDialog otherwise it would appear as two separate windows...
    WEll, you don't need to (and you must not) assign your propertysheet pointer to m_pMainWnd if the propertysheet is NOT a main window. The Framework does use such an assignment for cleanup and only for the main App window.

    On the other hand you could redesign you App using the propertysheet as the main window (instead of a child window of a "default" dialog) or you could place the propertysheet on the main dialog as the child modeless window.
    Quote Originally Posted by npuleio View Post
    2) doesn't exists any PSH_NOblahblah flag to hide IDOK, IDCANCEL and IDHELP like that PSH_NOAPPLYNOW?...
    Hmm... Why do you need all these PSH_NO...?
    What is wrong for you just to write:
    Code:
    GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); 
    GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE);
    Or you could use modeless propertysheet rather than the modal one - in this case all these button would be hidden by Framework.
    Victor Nijegorodov

  9. #9
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    The matter is in fact
    GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    doesn't work here probably because for a conflict using a propertysheet as modal and trying to use it as modeless..

    I was thinking about modal propertysheet following Arjay's example to manage "pages" as document/views to pass informations between pages...
    the point I don't know if Document/View methodology would be applied to modeless propertysheet/pages....

    Having in fact modeless windows (presence of CDialog) makes me a bit confusing about Document/View idea...

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Quote Originally Posted by npuleio View Post
    The matter is in fact
    GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    doesn't work here probably because for a conflict using a propertysheet as modal and trying to use it as modeless...
    1. Define "doesn't work".
    2. Where are you calling this line from?
    Victor Nijegorodov

  11. #11
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Hello VictorN,

    since I was calling PropertySheet class from CDialog due to "insert inside" if I put GetDlgItem(IDOK)->ShowWindow(SW_HIDE); in the PropertySheet's ctor or also right after declared it returned a severe error that interrupted running.

    At least now I'm trying to remove PropertySheet class and use instead a PropertySheet object (the modeless way) and actually I'm trying to set the OnWindowPosChanged correctly to resize the PropertySheet inside the client rect.
    But if I do:

    this->GetClientRect( &clientrect );
    CTabCtrl* poControl = m_pPropertySheet->GetTabControl();
    poControl->SetWindowPos(&CWnd::wndBottom, 0, 0,
    clientrect.right - 10, clientrect.bottom - 15, SWP_NOMOVE | SWP_NOZORDER);
    m_pPropertySheet->SetWindowPos(&CWnd::wndBottom, 0, 0,
    clientrect.right - 10, clientrect.bottom - 15, SWP_NOMOVE | SWP_NOZORDER);

    I can't see right and bottom borders... :-/

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Quote Originally Posted by npuleio View Post
    Hello VictorN,

    since I was calling PropertySheet class from CDialog due to "insert inside" if I put GetDlgItem(IDOK)->ShowWindow(SW_HIDE); in the PropertySheet's ctor or also right after declared it returned a severe error that interrupted running.
    You may not:
    a) accessing modal PropertySheet class controls from the outside the PropertySheet class;
    b) accessing PropertySheet class controls until there have been created (they are created during the CPropertySheet::OnInitDialog() call)

    So what you should do is:
    1. implement (override) CPropertySheet::OnInitDialog() method
    2. somewhere after CPropertySheet::OnInitDialog() call place these line to hide OK, Cancel, Apply controls
    Victor Nijegorodov

  13. #13
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Well....as I said now I am calling PropertySheet modelessly...
    but still I have difficulties to resize correctly in the OnWindowPosChanged...

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

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    Quote Originally Posted by npuleio View Post
    Well....as I said now I am calling PropertySheet modelessly...
    Oh, yes, now I see it.
    But since you wrote about it very unclear:
    Quote Originally Posted by npuleio View Post
    ... At least now I'm trying to remove PropertySheet class and use instead a PropertySheet object (the modeless way) ...
    (what does it mean "to remove PropertySheet class and use instead a PropertySheet object"?) so I just omited the rest of text...

    What exactly are you trying to achieve with the sheet resizing and what do all these magic numbers (10, 15) mean?

    Besides, please always use Code tags and indentations while posting code snippets.
    About Code tags: http://www.codeguru.com/forum/misc.php?do=bbcode
    Victor Nijegorodov

  15. #15
    Join Date
    Aug 2009
    Posts
    84

    Re: [MFC] DDX/DDV and DoDataExchange between nested PropertySheets

    In this case I have this:

    Code:
    class CMyDialogDlg : public CDialog
    {
    // Construction
    public:
    	CMyDialogDlg(CWnd* pParent = NULL);	// standard constructor
    
    // Dialog Data
    	enum { IDD = IDD_MFC_ANALYZER_GUI_DIALOG };
    
    	protected:
    	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
    
    	//bool m_bIsBasicConfEnabled;
    
    // Implementation
    private:
    
    public:
    	CString foldervariable;
    	BOOL m_bIsInitialized;
    
    protected:
    	HICON m_hIcon;
    	CPropertySheet* m_poPropSheet;
    
    	CPage_Config* pageConfig;
    	CPage_Profile* pageProfile;
    	CPage_Monitor* pageMonitor;
    	CPage_Trace* pageTrace;
    
    	CTabCtrl* poControl;
    
    	// Generated message map functions
    	virtual BOOL OnInitDialog();
    	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    	afx_msg void OnPaint();
    	afx_msg HCURSOR OnQueryDragIcon();
    	DECLARE_MESSAGE_MAP()
    	void OnExit();
    public:
    	afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
    	afx_msg void OnSize(UINT nType, int cx, int cy);
    	
    };
    
    CMyDialogDlg::CMyDialogDlg(CWnd* pParent /*=NULL*/)
    	: CDialog(CMyDialogDlg::IDD, pParent)
    	, m_bIsInitialized(FALSE)
    {
    	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    }
    
    BOOL CMyDialogDlg::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    
    	// Add "About..." menu item to system menu.
    	// IDM_ABOUTBOX must be in the system command range.
    	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    	ASSERT(IDM_ABOUTBOX < 0xF000);
    
    	AfxInitRichEdit2();
    
    	CMenu* pSysMenu = GetSystemMenu(FALSE);
    	if (pSysMenu != NULL)
    	{
    		BOOL bNameValid;
    		CString strAboutMenu;
    		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
    		ASSERT(bNameValid);
    		if (!strAboutMenu.IsEmpty())
    		{
    			pSysMenu->AppendMenu(MF_SEPARATOR);
    			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    		}
    	}
    
    	// Set the icon for this dialog.  The framework does this automatically
    	//  when the application's main window is not a dialog
    	SetIcon(m_hIcon, TRUE);			// Set big icon
    	SetIcon(m_hIcon, FALSE);		// Set small icon
    
    	// Extra initialization here
    	m_poPropSheet = new CPropertySheet();
    
    	pageConfig = new CPage_Config( m_poPropSheet );
    	m_poPropSheet->AddPage(pageConfig);
    
    	DWORD dwStyle = WS_VISIBLE | WS_CHILD;        
    	DWORD dwExStyle = WS_EX_LEFT|WS_EX_CONTROLPARENT;
    	if ( !m_poPropSheet->Create(this, dwStyle, dwExStyle) )
    	{
    		DestroyWindow();
    		return FALSE;
    	}
    
    	poControl = m_poPropSheet->GetTabControl();
    	
    	m_bIsInitialized = true;
    
    	return TRUE;  // return TRUE  unless you set the focus to a control
    }
    
    void CMyDialogDlg::OnWindowPosChanged(WINDOWPOS* lpwndpos)
    {
    	CDialog::OnWindowPosChanged(lpwndpos);
    
    	if( m_bIsInitialized )	
    	{		
    		m_poPropSheet->SetWindowPos( NULL, 0, 0, 
    									 lpwndpos->cx - 10, lpwndpos->cy - 25, SWP_NOMOVE|SWP_NOZORDER ); 		
    
    		poControl->SetWindowPos( NULL, 0, 0, 
    		  						 lpwndpos->cx - 20, lpwndpos->cy - 35, SWP_NOMOVE|SWP_NOZORDER );
    	}
    }
    and I obtain the bottom goes out of the window as you can see the screenshot at this url:

    http://img222.imageshack.us/img222/4...reenshotmt.jpg

    So propertysheet's bottom is supposed to be inside the CDialog when it isn't...

Page 1 of 3 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