Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Response tables for class templates

Posted on 1997-03-01
1
Medium Priority
?
264 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 100 total points
ID: 1161986
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

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

876 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