Solved

Template window class - How to map messages ?

Posted on 2002-06-26
5
375 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
isEverywhere  challenge 19 64
java ^ examples 8 57
Not needed 13 53
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

14 Experts available now in Live!

Get 1:1 Help Now