Solved

Problems updating CPropertSheet.

Posted on 1998-11-16
3
181 Views
Last Modified: 2013-11-20
I´ve created a CDialog based app. And in Init Dialog I use this code:
PropertySheet.AddPage(&StartMenuDlg);
PropertySheet.AddPage(&DesktopDlg);
PropertySheet.Create(this, WS_CHILD | WS_VISIBLE, 0);
PropertySheet.ModifyStyleEx ( 0,WS_EX_CONTROLPARENT );
PropertySheet.ModifyStyle ( 0,WS_TABSTOP );

So the Property sheet are added on the main dialog. I´v made 2 Dialogs which are the 2 tabs. Now I have a button on the main dialog on when it´s clicked I need to use UpdateData(TRUE) so that the variables will recive the right value. If I use UpdateData on the sheet that are visible on top - No Problem. Then when I use it on the sheet thats not visible, the bottom one the app crashes. Can anyone help me out how I can update my variables in both my "dialog" sheets. I´m quite new at MFC so a easy answer would help me alot.
Thanx...
0
Comment
Question by:joakimf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Author Comment

by:joakimf
ID: 1324763
Adjusted points to 70
0
 

Accepted Solution

by:
n023y earned 70 total points
ID: 1324764
CPropertySheet includes some efficiency where the pages are not created until they are switched to. Therefore you are attempting to access a window that does not exist.
Two options are availble to you

1. Handle the fact that your window may not exist, by performing the following
In the DoDataExchange routine,
void DesktopDlg::DoDataExchange(CDataExchange *pDX)
{
   if (!::IsWindow(m_hWnd))
      return;
   //your data exhcange calls go here...
}
and perform the initial varaible value update in the constructor or InitDialog of the property page class

2. The slower alternative is to make sure that all pages are created by calling a code fragment similar to the following

//switch off redraw to prevent screen flicker PropertySheet.SetRedraw(FALSE);  

//load each page
for (int nLoop = PropertySheet.GetPageCount() - 1; nLoop >= 0; nLoop--)
{
    PropertySheet.SetActivePage(nLoop);
}

//reallow painting of property sheet
PropertySheet.SetRedraw(TRUE);

0
 
LVL 1

Author Comment

by:joakimf
ID: 1324765
Thank you for that excellent answer...
Enjoy the points..
//joakimf
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question