Solved

Response tables for class templates

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need some help with listview limit text 20 103
FMX enumerated colours 2 98
thread-safe code in c++ 2 99
Printing the elements of a set declared inside a map in C++. 3 47
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.

785 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