Solved

Response tables for class templates

Posted on 1997-03-01
1
229 Views
Last Modified: 2008-03-10
Using BC++ 5.01, I'm developing a class tempate for TEdit:

template<class T> class TMyEdit : public TEdit { ... };

My aim is getting TEdits for different types of input.
The TMyEdit template installs a connected TMyFilterValidator
template class for the same input type (e.g. <float>). Using
strstreams this validator template is able to checkt the string
input, to convert it to the desired data type (float etc.) and
to return the correct data size for all kinds of input.
This is easy, but I'm having troubles constructing a generic
message response table for the template. I can do it for single
instances like TMyEdit<float>, but can't find a valid syntax
for the class template itself. A workaround would be an
intermediate non-template class between TEdit and the
TMyEdit template with a response table and virtual response
functions, but I'd prefer to have the response table in the
class template itself.

Is it possible to define a response table for class templates
and what would be the exact syntax for DECLARE_ and
DEFINE_RESPONSE_TABLE? Please don't give hints about TEdit
and TValidator - this is just an example.

Please tell me if this is possible or not. If you have a
solution that works but is worth more than what I offered,
just contact me.

Greetings,
hagix@aol.com

0
Comment
Question by:hagix
1 Comment
 
LVL 3

Accepted Solution

by:
gaohong earned 50 total points
Comment Utility
If all you want to do is make editor control to accept different
type of input, then use template is really not the way to go.

TEdit itself is a predefined window class. To get what you want all you need is to derive a your TYourEdit with extra parameter to indicate what kind of input editor wanted.  The message response table can only let you handle when char is typed or changed (those EV_EN_XXXX) which never tells you input character is number or char. So response table
can not do what you want, instead you should use TFilterValidator(...) to setup different mask for your type of editor. e.g. Only positive numbers  

      Column = new TEdit(this, IDC_EEDITCOLUMN);
      Column->SetValidator( new TFilterValidator("0-9") );


Hope this solves your problem

Gaohong Xie

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

9 Experts available now in Live!

Get 1:1 Help Now