15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CPropertyPage::QuerySiblings

Doug Reese -- drrhab@cts.com
Tuesday, January 09, 1996

Does anyone have any insight as to how the QuerySiblings method might be =
used?  Here's what I'm trying to accomplish:  I have a CPropertySheet =
derived class that contains 6 CPropertyPage derived pages.  When a =
certain button (a member of my CPropertySheet derived class) is pressed, =
I want to call a function in each of my CPropertyPage derived classes =
that is not an override of a base class function.  This function has the =
same name in each of the pages.  I know how to iterate through each of =
the pages from my CPropertySheet class, but since all CPropertySheet =
knows about is CPropertyPages I don't know how to get to the function in =
my classes derived from CPropertyPage.  Is QuerySiblings the way to go =
or is there a better way?

Doug



Dale Wilson -- dale@dra.com
Thursday, January 11, 1996

[Mini-digest: 3 responses]


> Subject: CPropertyPage::QuerySiblings
> Date: Tuesday, January 09, 1996 7:55PM
>
> Does anyone have any insight as to how the QuerySiblings method might be =
> used?  Here's what I'm trying to accomplish:  I have a CPropertySheet =
> derived class that contains 6 CPropertyPage derived pages.  When a =
> certain button (a member of my CPropertySheet derived class) is pressed, =
> I want to call a function in each of my CPropertyPage derived classes =
> that is not an override of a base class function.  This function has the =
> same name in each of the pages.  I know how to iterate through each of =
> the pages from my CPropertySheet class, but since all CPropertySheet =
> knows about is CPropertyPages I don't know how to get to the function in =
> my classes derived from CPropertyPage.  Is QuerySiblings the way to go =
> or is there a better way?
>
> Doug

class CBasePage : public CPropertyPage
{
    DECLARE_DYNAMIC(CBasePage)
    virtual void TheCommonFunction() = 0;
    void CallSiblings();
}
class CPage0 : public CBasePage
{
   virtual void TheCommonFunction();
}
...etc...
CBasePage::CallSiblings()
{
    CPropertyPage *pSibling;
    for each sibling
    {
         if(pSibling->IsKindOf(RUNTIME_CLASS(CBasePage)))
         {
              CBasePage * pBaseSib = (CBasePage *)pSibling;
               pBaseSib->TheCommonFunction();
          }
     }
}

#pragma Details left to the imagination

dale@dra.com

-----From: Brad Wilson 

>> Does anyone have any insight as to how the QuerySiblings
>> method might be used?

I needed to do something just like your scenario.  I created a
derived class from CPropertySheet and in there I kept pointers
to all the created pages (in the constructor of the overrode
CPropertySheet I created and added all the property pages).

That gave me the flexibility I needed.

Good luck!
Brad

--
class CBradWilson : public CWorldWatchProgrammingTeam {
  public:
    CString GetInetAddr()   { return CString("bradw@exptech.com");      }
    CString GetPhone()      { return CString("+1 (810) 620-9803");      }
    CString GetURL()        { return CString("http://www.exptech.com"); }
    CString GetDisclaimer() { return CString("All I say is fact :-p");  }
};

"Money is the living power that dies without its root. Money will not serve
 the mind that cannot match it. Is this the reason why you call it evil?"

-----From: "Aravind Balakrishnan(abalakri@us.oracle.com)" 

I can think of two ways: 
1.) Have a class derived from CPropertyPage, say CInterPage.  Make all your 
pages derive from CInterPage.  Have a virtual function in CInterPage, 
overridden by every property page.  Then, the class derived from 
CPropertySheet can cast the page to CInterPage() and call the virtual function. 
2.) Have a private message for the page.  But this also needs another 
intermediate class.  
 
My choice is 1.) 
 
Cheers,   
Aravind.   
===   
 
Aravind Balakrishnan  
Systems Management Products, Oracle Corp. 
(415)506-0432 




| Вернуться в корень Архива |