How to change to another Property Sheet and launch..

This might be blindingly easy, it's just new to me.

I have an application that is a single CPropertySheet containing several CPropertyPage instances.

void CScopePropSheet::AddControlPages()
{
      m_pSystemPage = new CSystemPage();
      m_pImagePage = new CImagePage();
        //... etc

       AddPage(m_pSystemPage );      
       AddPage(m_pImagePage );
       // ...etc
}

Say the user is working within m_pImagePage.  Clearly they could click the  System tab and change to that tab.  But I want to add a mechanism, whereby clicking a certain area in the image that is shown in Image Page, will force a transition to System Page, as well as call a method that m_pSystemPage implements.

(they could hit the System tab, and then click a button on the System page, but I need to essentially create  a "shortcut" from the Image Page that will change pages and call  initialization code in one click, under the hood)

All my click handling is in place, I just need to know how to make that page the active page (w/o the user having to hit the tab) and then execute a method within that page.

I hope that made sense :)

Thanks
-Paul
PMH4514Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AaronReamsCommented:
Here is how you would go about it...  Just call a public member function of CSystemPage and then call SetActivePage in the property sheet.  Good luck -Aaron

// in class CSystemPage header file
public:
void DoSomething() { MessageBox("Do something");}

// in class CImagePage source file
void CImagePage::YouClickHandler(...)
{
((CScopePropSheet)GetParent())->m_pSystemPage->DoSomething();
((CScopePropSheet)GetParent())->SetActivePage(((CScopePropSheet)GetParent())->m_pSystemPage);
}



0
PMH4514Author Commented:
hmm.. I get these compile errors:

error C2440: 'type cast' : cannot convert from 'class CWnd *' to 'class CScopePropSheet'
error C2227: left of '->m_pScopePage' must point to class/struct/union
0
PMH4514Author Commented:
I can get basically the same thing to work, if I add a private member variable to my ImagePage of type CScopePropSheet, and then set it to "this" within the CScopePropSheeet after instantiating the ImagePage:

void CScopePropSheet::AddControlPages()
{
  m_pImagePage = new CImagePage();
  AddPage(m_pImagePage);
  m_pImagePage->SetPropSheetParent(this);  // accessor method I added to CImagePage to set private pointer to the prop sheet.

//..

}

then within my CImagePage

// your lines
//  ((CScopePropSheet)GetParent())->m_pSystemPage->DoSomething();
//  ((CScopePropSheet)GetParent())->SetActivePage(((CScopePropSheet)GetParent())->m_pSystemPage);            

// my lines, which call upon my private pointer which now points to my parent
m_pScopePropSheet->m_pSystemPage->DoSomething();
m_pScopePropSheet->SetActivePage(m_pScopePropSheet->m_pSystemPage);            


But while this is working,  I don't like that I had to explicitly store a pointer to the parent property sheet.. I must be doing something wrong.


thoughts?

Thanks

-Paul
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

AaronReamsCommented:
Sorry, this

((CScopePropSheet)GetParent())->

should be

((CScopePropSheet*)GetParent())->
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AaronReamsCommented:
let me know if that works for ya.  cheers -Aaron
0
PMH4514Author Commented:
ahh.. perfect.. I should have seen that too.

thanks!
-paul
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.