Solved

Template window class - How to map messages ?

Posted on 2002-06-26
5
396 Views
Last Modified: 2013-11-20
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 ?
0
Comment
Question by:gurly
  • 2
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 7110389
It should read

BEGIN_MESSAGE_MAP(CMyWnd<[the number of colums you used to instantiate CMyWnd]>, CWnd)
0
 
LVL 1

Author Comment

by:gurly
ID: 7110401
Yes, but when I write my class I still don't know the number of columns.
That's why it is a template.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7110423
I know - that is a Catch22, but that's the way it is...
0
 
LVL 1

Author Comment

by:gurly
ID: 7110448
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 ?
0
 
LVL 3

Expert Comment

by:Melange
ID: 7111246
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.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now