The main purpose for this is code compression (write less code.)
instead of writing this
(which works very fine):
template <class tbase="">
class COfficeBorderEx : public TBase
{
protected:
COfficeBorderEx(UINT nIDTemplate) : TBase(nIDTemplate) {
}
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_NCPAINT:
{
TBase::WindowProc(message, wParam, lParam);
.
.
.
return 0; }
break;
case WM_CREATE:
{
if (TBase::WindowProc(message, wParam, lParam) == -1)
return -1;
.
.
.
return 0; }
break;
case WM_NCCALCSIZE:
{
LRESULT lResult = TBase::WindowProc(message, wParam, lParam);
.
.
.
return lResult;
}
break;
}
return TBase::WindowProc(message, wParam, lParam);
}
};
I would write just this
(which didn't worked for me):
template <class TBase>
class COfficeBorderEx : public COfficeBorder<TBase>
{
protected:
COfficeBorderEx(UINT nIDTemplate) : TBase(nIDTemplate)
{
}
};
But I get a compiler error that says:
error C2512: 'COfficeBorderEx' : no appropriate default constructor available
I guess It is not possible :(