Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

override gettext and settext method for TEdit

466 views
Skip to first unread message

Inung Huang

unread,
Jan 13, 2003, 11:06:55 PM1/13/03
to
I have a TMyEdit inherited from TEdit which only allow user enter numeric
value.

I would like to add a precision field to limit the display of the numeric
value.

I wanted to override the SetText and GetText methods, since I will change
the text property of TMyEdit.

For example, if the value of MyEdit1 is 3.1415926 and precision set up 2
then I want to display 3.14 even physical value is 3.1415926.

After I investigate the GetText and SetText method which inherited from
TControl and using Window Message.

Are there any easy way to override the SetText and GetText method of
TControl?

Thanks in advance.


Inung Huang

Inung Huang

unread,
Jan 14, 2003, 9:22:13 AM1/14/03
to
Thanks for the information.

Inung Huang
"Rafael Blanco González" <Rafabg1974 at terra dot es> wrote in message
news:3e23...@newsgroups.borland.com...
> TControl.GetText and TControl.SetText cannot be overriden since they are
not
> virtual (nor dynamic). Anyway, if I were you a would override TWinControl
> DoEnter and DoExit procedures, and change Text property on it. You
probably
> (depends on what you want) will need another private variable to store the
value
> typed instead of then value shown.
>
> ------------------------------------
> Rafael Blanco González
> Team Manager - Grupo Anjoca
> La Coruña - Spain (UE)
>
> AntiSpam: rafabg 1974 at terra dot es
>
>
> "Inung Huang" <inu...@videotron.ca> escribió en el mensaje
> news:3e238ce6$1...@newsgroups.borland.com...

Maris Janis Vasilevskis

unread,
Jan 14, 2003, 3:36:33 PM1/14/03
to
Another solution.
GetText/SetText are reduced to WM_GETTEXT/WM_SETTEXT.

In this place, you can override default action by invoking message handlers
procedure WMGetText(var Message: TWMGetText); message WM_GETTEXT;
procedure WMGetTextLength(var Message: TWMGetTextLength); message WM_GETTEXTLENGTH;
procedure WMSetText(var Message: TWMSetText); message WM_SETTEXT;

Or, override
procedure DefaultHandler(var Message); override;

Mahris

"Rafael Blanco González" wrote:
> TControl.GetText and TControl.SetText cannot be overriden since they are not
> virtual (nor dynamic). Anyway, if I were you a would override TWinControl
> DoEnter and DoExit procedures, and change Text property on it. You probably
> (depends on what you want) will need another private variable to store the value
> typed instead of then value shown.
>

> "Inung Huang" <inu...@videotron.ca> escribió en el mensaje

0 new messages