Solved

Response tables for class templates

Posted on 1997-03-01
1
236 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

910 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

24 Experts available now in Live!

Get 1:1 Help Now