[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

using property sheets

Posted on 2002-04-12
3
Medium Priority
?
204 Views
Last Modified: 2013-11-20
I have an application that has a propertySheet with two propertyPages. The first page contains the person's name and address. The second page contains the person's name and some other information. In addition on each page I have a 'next' and 'prev' buttons that goes to the next or previous personnel record.
1) how can I load the person's name on both pages at once? Can I do it on the onInitDlg event of the propertySheet? (actually there is more information repeated on each page than the person's name)
2) how do I load and save the data from each page? do I have to do it when going in and out of each page? or can I do it when the 'next' or 'prev' buttons are pressed?

thanks
0
Comment
Question by:el_rooky
[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
3 Comments
 
LVL 3

Expert Comment

by:Crius
ID: 6937117
The property sheet is a common place to store things that can be accessed by all property pages. If you want to have the name appear on more than 1 page, you'll have to store it there.

Each property page is a window, a dialog like window that is hidden when you move from one page to another. They will maintain their state even after you've moved to another property sheet.

You can not load the name onto the property pages with OnInitDialog because that is only called once. You could likely do it in the property sheet when it detects a tab change (think of the property sheet as like a tab control where each tab references a property sheet), or you could have it read from the property sheet when the window becomes visible, or active...

There is no need to load or save data for each page since when you leave the page, the data does not go away. You can attach the data to variables using the class wizard though, and when the property sheet is closed, just iterate through all the property pages making use of the variables as you see fit..
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 600 total points
ID: 6938622
There are several ways to do this, and it takes some planning.  I assume that you have a CRecordset that contains the personell records.  You need to make that available to both pages.

The simplest way to do that is to make it a global variable.  The object-oriented way to do that is to make it a member of the CPropertySheet-derived object that contains both pages.  I'll assume the latter and call the propertysheet object CMySheet and assume that it has a recordset member named m_cRecSetPersonell.

When you instantiate CMySheet, open the recordset and populate all of the fields of all of the pages:

CMySheet cSheet( "My title" );

cSheet.AddPage( m_cPg1 );
cSheet.AddPage( m_cPg2 );

m_cRecSetPersonell.Open(....)

cSheet.m_cPg1.m_sLastName= m_cRecSetPersonell.m_LastName;
cSheet.m_cPg2.m_sSalary=   m_cRecSetPersonell.m_Salary;
(etc)

cSheet.DoModal();

==--=-==-
Next, you need to do somthing like this in the on click handlers in both pages:

void CDlgPg_1::OnNext()
{
   CMySheet* pSheet= (CMySheet*)GetParent();
   pSheet->m_RecSetPersonell.MoveNext();
   m_lastName= pSheet->m_RecSetPersonell.m_LastName;
   ...(etc)...
   UpdateData( FALSE ); // display the data
}

Finally, when the user clicks th tab to view the other page, you need to updat the data there, also.  So add an OnSetActive handler:

void CDlgPg_1::OnSetActive()
{
   CMySheet* pSheet= (CMySheet*)GetParent();
   pSheet->m_RecSetPersonell.MoveNext();
   m_lastName= pSheet->m_RecSetPersonell.m_LastName;
   ...(etc)...
   UpdateData( FALSE ); // display the data
}

=-=-=-=-
Notice that both fns do the same thing, so you might as well right a member fn that transfers the data from the recordset into the member variables and then calls UpdateData(FALSE).  And why put it in two places?  Instead, you could add a member to CMySheet that uses code like:

void CMySheet::LoadVars()
{
   m_cPg1.m_LastName= m_RecSetPersonell.m_LastName;
   ...(etc)...
   m_cPg2.m_Salary= m_RecSetPersonell.m_Salary;
   ...etc..
}

Then both your OnSetActivate and OnSomeButton hander could call:

   CMySheet* pSheet= (CMySheet*)GetParent();
   pSheet->LoadVars();
   UpdateData( FALSE );

You could also call LoadVars() right before cSheet.DoModal().

=-=-=-=-=-=-=-=-=-=-=-=-
If there is any part of this that you don't understand, I'll be glad to explain.

-- Dan
0
 

Author Comment

by:el_rooky
ID: 6942801
Dan,
It works great!
Thanks a lot.
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 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