Solved

using property sheets

Posted on 2002-04-12
3
198 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 150 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

Technology Partners: 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
Folder Comparison 12 55
Best tools for Backup and restore of Wordpress site 6 58
VBA "SendKeys" Syntax for Multiple Keystrokes 7 126
Message not shown 5 87
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

696 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