Solved

Problems updating CPropertSheet.

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 179
MaxSpan challenge 9 140
scoreUp challenge 14 74
Excel file not created as expected 7 111
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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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