Discussion:
focus controls
(too old to reply)
jason madrigal
2011-07-21 18:09:33 UTC
Permalink
Hi I'm new in delphi pascal...
that I'm trying is to focus an edit control in an button click event.

thanks in advance for the help
Ph. B.
2011-07-21 21:18:15 UTC
Permalink
Post by jason madrigal
Hi I'm new in delphi pascal...
that I'm trying is to focus an edit control in an button click event.
thanks in advance for the help
Hi,

First, I suppose you have put a TButton control and a TEdit control on
the form.
Next, link a procedure to the "OnClick" button's event, then, in the
code of this procedure, type

Edit1.SetFocus;

Compile, run and enjoy ;-)
--
Philippe.
P E Schoen
2011-07-23 01:23:22 UTC
Permalink
Post by Ph. B.
Post by jason madrigal
Hi I'm new in delphi pascal...
that I'm trying is to focus an edit control in an button click event.
thanks in advance for the help
First, I suppose you have put a TButton control and a TEdit control
on the form.
Next, link a procedure to the "OnClick" button's event, then, in
the code of this procedure, type
Edit1.SetFocus;
Compile, run and enjoy ;-)
That will probably work OK. But I have had some problems setting focus of
one control from another's onClick event. At the very least, make sure the
SetFocus is the last line of the onClick handler. Otherwise, maybe the
SetFocus should be in an OnMouseUp event, or even better, OnBlur or
OnLoseFocus, if those are available. It's been awhile since I worked with
those issues, or even Delphi itself.

Paul
Jamie
2011-07-23 15:02:58 UTC
Permalink
Post by P E Schoen
Post by Ph. B.
Post by jason madrigal
Hi I'm new in delphi pascal...
that I'm trying is to focus an edit control in an button click event.
thanks in advance for the help
First, I suppose you have put a TButton control and a TEdit control
on the form.
Next, link a procedure to the "OnClick" button's event, then, in
the code of this procedure, type
Edit1.SetFocus;
Compile, run and enjoy ;-)
That will probably work OK. But I have had some problems setting focus
of one control from another's onClick event. At the very least, make
sure the SetFocus is the last line of the onClick handler. Otherwise,
maybe the SetFocus should be in an OnMouseUp event, or even better,
OnBlur or OnLoseFocus, if those are available. It's been awhile since I
worked with those issues, or even Delphi itself.
Paul
Setting the Parent form.activeControl := ?? should do..

Jamie

Loading...