Solved

Problems updating CPropertSheet.

Posted on 1998-11-16
3
176 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dog bark java program 15 87
has22 challenge 11 78
only14 challenge 19 68
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 184
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

948 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now