Solved

Response tables for class templates

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

726 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