Link to home
Start Free TrialLog in
Avatar of gurly
gurly

asked on

Template window class - How to map messages ?

Hi,

I have a CWnd derived class that has to be a template class:
template <UINT COLUMNS>
class CMyWnd : public CWnd
{
  ...
};

When I try to use the BEGIN_MESSAGE_MAP macro I get compilation errors.
BEGIN_MESSAGE_MAP(CMyWnd, CWnd)
>> error C2955: 'CMyWnd' use of class template requires template argument list.

What is the right way to write this ?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gurly
gurly

ASKER

Yes, but when I write my class I still don't know the number of columns.
That's why it is a template.
I know - that is a Catch22, but that's the way it is...
Avatar of gurly

ASKER

So what you're saying is that it can't be done.
A CWnd derived that is a template and also needs to map messages ?
Can I somehow call the BEGIN_MESSAGE_MAP where I instatiate CMyClass ?
The BEGIN_MESSAGE_MAP macro is actually part of the instantiation of the class, not the declaration. You would need a separate BEGIN_MESSAGE_MAP section for every separate instantiation of the class.

Just by using the BEGIN_MESSAGE_MAP macro you would be creating an instance of the class, that's why you would need to specify the number of columns as part of the macro.