[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

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
0
PMH4514
Asked:
PMH4514
  • 3
  • 3
1 Solution
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
AaronReamsCommented:
Sorry, this

((CScopePropSheet)GetParent())->

should be

((CScopePropSheet*)GetParent())->
0
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now