Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Template window class - How to map messages ?

Posted on 2002-06-26
5
Medium Priority
?
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 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