Solved

Problems updating CPropertSheet.

Posted on 1998-11-16
3
175 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
Comment Utility
Adjusted points to 70
0
 

Accepted Solution

by:
n023y earned 70 total points
Comment Utility
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
Comment Utility
Thank you for that excellent answer...
Enjoy the points..
//joakimf
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 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

11 Experts available now in Live!

Get 1:1 Help Now