Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problems updating CPropertSheet.

Posted on 1998-11-16
3
Medium Priority
?
188 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 280 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

927 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