Deriving from a class derived from a CDialog
Hello,
Hopefully the title wasn't too confusing. I have a problem with the class wizard.
For classes which are derived from CDialog via 2 hops he looses the ability to
generate event handlers. If I add the event handlers by hand things work but the
automatic 'wizard' things in the resource editor no longer work.
1) What I wanted to achive and did
The project (a dialog based app) uses a tabulator control to display various
pages to the user where he can change values, send commands to an external
device and see the results. But certain operations have to be performed always
when a tab is selected or deselcted (configuration/initialization and reseting
of the external device). In the original approach the Tabs where directly derived
from CDialog and the CMyTabCtrl (derived from CTabCtrl) new which methods to call
for starting/stopping a tab.
I tried to make this more C++ like by introducing an additional class CTab dervied
from CDialog which defines two virtual methods TabSelected, TabDeselected and all Tabs are
now derived from that new class. Additionally as CTab is tightly related to
the tab control I made it a public inner class of the CMyTab Ctrl class.
Essential C++ code:
class CMyTabCtrl :: public CTabCtrl
{
public:
class CTab : public CDialog
{
public:
explicit CTab(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL)
: CDialog(lpszTemplateName, pParentWnd)
{};
explicit CTab(UINT nIDTemplate, CWnd* pParentWnd = NULL)
: CDialog(nIDTemplate, pParentWnd)
{};
CTab() : CDialog()
{};
virtual void TabSelected()
{}
virtual void TabDeselected()
{}
};
// other methods to add and setup the needed tabs
}
// Tabs are now implemented via
class CSomeTab :: public CMyTabCtrl::CTab
2) What happened
Somehow the class wizard lost any ability to generate event handlers for all the
classes derived from CMyTabCtrl::CTab.
I suspect it has something to do with all the DECLARE_DYNAMIC and DECLARE_MESSAGE_MAP
macros but I do not have enough insight to point to the problem.
I tried to use DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC but it seems that those macros
choke on inner classes.
Because
IMPLEMENT_DYNAMIC(CMyTabCtrl::CTab, CDialog); // and the needed DECLARE_DYNAMIC in the header file
leads to error messages from the compiler regarding the '::'.
Best regards,
Oliver