Dirk_Sander
asked on
Call DEFINE_RESPONSE_TABLEx 4 templates
How 2 call DEFINE_RESPONSE_TABLEx 4 templates ?
I want 2 build a template 4 Dialog witch can be called
as normal 'TDialog' or as 'TOleDialog' so this can be done :
************************** ********** *******
TMyDialog::TMyDialog(TWind ow * AParent)
: TDlgBase<TDialog>
==> TMyDialog acts like 'TDialog'
TMyDialog::TMyDialog(TWind ow * AParent)
: TDlgBase<TOleDialog>
==> TMyDialog acts like 'TOleDialog'
************************** ********** *******
I have done all the code but now I don´t know how to
call the DEFINE_RESPONSE_TABLEx, DECLARE_RESPONSE_TABLE Makros ?
************************** ********** *******
Examlpe Header :
template <class TDlg> class TDlgBase
: public TDlg
{
public:
THelpDlgBase(TWindow *AParent);
protected:
void EvNCPaint();
DECLARE_RESPONSE_TABLE( TDlgBase ); /*????*/
};
************************** ********** ********
************************** ********** ********
Examlpe Cpp :
template <class TDlg>
TDlgBase<TDlg>::TDlgBase(T Window * AParent)
: TDlg(AParent)
{
}
template <class TDlg> inline void
THelpDlgBase<TDlg>::EvNCPa int()
{
TDlg::EvNCPaint();
}
DEFINE_RESPONSE_TABLE1( THelpDlgBase , TDlg ) /*?????*/
EV_WM_NCPAINT,
END_RESPONSE_TABLE;
************************** ********** ********
I want 2 build a template 4 Dialog witch can be called
as normal 'TDialog' or as 'TOleDialog' so this can be done :
**************************
TMyDialog::TMyDialog(TWind
: TDlgBase<TDialog>
==> TMyDialog acts like 'TDialog'
TMyDialog::TMyDialog(TWind
: TDlgBase<TOleDialog>
==> TMyDialog acts like 'TOleDialog'
**************************
I have done all the code but now I don´t know how to
call the DEFINE_RESPONSE_TABLEx, DECLARE_RESPONSE_TABLE Makros ?
**************************
Examlpe Header :
template <class TDlg> class TDlgBase
: public TDlg
{
public:
THelpDlgBase(TWindow *AParent);
protected:
void EvNCPaint();
DECLARE_RESPONSE_TABLE( TDlgBase ); /*????*/
};
**************************
**************************
Examlpe Cpp :
template <class TDlg>
TDlgBase<TDlg>::TDlgBase(T
: TDlg(AParent)
{
}
template <class TDlg> inline void
THelpDlgBase<TDlg>::EvNCPa
{
TDlg::EvNCPaint();
}
DEFINE_RESPONSE_TABLE1( THelpDlgBase , TDlg ) /*?????*/
EV_WM_NCPAINT,
END_RESPONSE_TABLE;
**************************
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What luc said is right !
I want to use TDialog or TOleDialog as base class
but in TMyDialog there has to be the DEFINE_RESPONSE_TABLE macro !
But here is the solution :
In Header file all as usual :
************************** **********
DECLARE_RESPONSE_TABLE( TMyDialog );
************************** **********
In Cpp file a little workarround 4 the makro :
************************** ********** ********** ********** *****
template <class TDlgBase> inline bool
TMyDialog<TDlgBase>::Find( TEventInfo & eventInfo, TEqualOperator equal)
{
eventInfo.Object = (GENERIC*)this;
return SearchEntries((TGenericTab leEntry __RTFAR*)__entries, eventInfo, equal) ||
TDlgBase::Find(eventInfo, equal);
}
template <class TDlgBase> inline TResponseTableEntry<TMyDia log<TDlgBa se> >
__RTFAR TMyDialog<TDlgBase>::__ent ries[] =
{
EV_WM_NCPAINT,
EV_WM_ACTIVATE,
EV_WM_INITMENU,
EV_WM_PAINT,
EV_WM_SYSCOMMAND,
END_RESPONSE_TABLE;
************************** ********** ********** ********** *******
I want to use TDialog or TOleDialog as base class
but in TMyDialog there has to be the DEFINE_RESPONSE_TABLE macro !
But here is the solution :
In Header file all as usual :
**************************
DECLARE_RESPONSE_TABLE( TMyDialog );
**************************
In Cpp file a little workarround 4 the makro :
**************************
template <class TDlgBase> inline bool
TMyDialog<TDlgBase>::Find(
{
eventInfo.Object = (GENERIC*)this;
return SearchEntries((TGenericTab
TDlgBase::Find(eventInfo, equal);
}
template <class TDlgBase> inline TResponseTableEntry<TMyDia
__RTFAR TMyDialog<TDlgBase>::__ent
{
EV_WM_NCPAINT,
EV_WM_ACTIVATE,
EV_WM_INITMENU,
EV_WM_PAINT,
EV_WM_SYSCOMMAND,
END_RESPONSE_TABLE;
**************************
However, I think I have a (reusable) answer, requiring a few lines (8) of "code". Hint: take a look at owl/eventhan.h
.luc.