BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie Question about moving control/focus

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Graham A Welsh
Guest





PostPosted: Thu Oct 23, 2003 10:58 pm    Post subject: Newbie Question about moving control/focus Reply with quote



Hello All,

I am using Delphi 5 Pro on Win98 and am having problems returning focus
to the parent form of certain buttons.

I have a TForm with various components, edit boxes, labels, combobox,
grid and some buttons. The sequence is as follows:-

Once the form is created a choice is made from the dropdown list of the
combobox. Certain items of the grid are filled in based on this choice.
Other items are manually filled in.

When all input is finished then a 'Save' button is pressed, which saves
the input to a database.

The above sequence works correctly. My problem is how to return
control/focus to the parent form when processing by the Save button has
completed. At this point I need the parent form to be back in the same
condition as when it was created, so that fresh input may commence.

I also have a problem as to how I offer a choice with an Exit button,
i.e. Yes or No. How can I pass control back from the Exit button to the
component which had control before the Exit button was pressed.

I am sure the solutions to these problems are obvious and simple, but,
I'm just not seeing them at the moment.

Any help will be gratefully received.


--
Graham A Welsh
Targeted Software Solutions Ltd
To reply, change "limited" to "ltd" in Email Address
Back to top
Jon Jacobs
Guest





PostPosted: Thu Oct 23, 2003 11:21 pm    Post subject: Re: Newbie Question about moving control/focus Reply with quote



This is off the top of my head, but I seem to remember, that if you have an
OnEnter handler for your Exit button, ActiveControl will still be the
control you are coming from at that point. Save it into another variable of
type TWinControl, then, when you have received your yes or no input (in the
OnClick handler perhaps) - if it is no:don't exit, then you can restore
focus to the TWinControl you saved - perhaps by assigning it back to
ActiveControl.

Jon

"Graham A Welsh" <graham.welsh (AT) targeted-software-solutions (DOT) limited.uk> wrote
in message news:MPG.1a026d687f48a2da989684 (AT) newsgroups (DOT) borland.com...
Quote:
Hello All,

I am using Delphi 5 Pro on Win98 and am having problems returning focus
to the parent form of certain buttons.

I have a TForm with various components, edit boxes, labels, combobox,
grid and some buttons. The sequence is as follows:-

Once the form is created a choice is made from the dropdown list of the
combobox. Certain items of the grid are filled in based on this choice.
Other items are manually filled in.

When all input is finished then a 'Save' button is pressed, which saves
the input to a database.

The above sequence works correctly. My problem is how to return
control/focus to the parent form when processing by the Save button has
completed. At this point I need the parent form to be back in the same
condition as when it was created, so that fresh input may commence.

I also have a problem as to how I offer a choice with an Exit button,
i.e. Yes or No. How can I pass control back from the Exit button to the
component which had control before the Exit button was pressed.

I am sure the solutions to these problems are obvious and simple, but,
I'm just not seeing them at the moment.

Any help will be gratefully received.


--
Graham A Welsh
Targeted Software Solutions Ltd
To reply, change "limited" to "ltd" in Email Address



Back to top
Kurt Barthelmess
Guest





PostPosted: Fri Oct 24, 2003 11:30 am    Post subject: Re: Newbie Question about moving control/focus Reply with quote



Graham A Welsh <graham.welsh (AT) targeted-software-solutions (DOT) limited.uk>
wrote:

Quote:
My problem is how to return
control/focus to the parent form when processing by the Save button has
completed. At this point I need the parent form to be back in the same
condition as when it was created, so that fresh input may commence.

There are two parts to this: a) Clearing out the old input data so
that the user starts frash, and b) tweaking the focus.

On a), you may want to write a method that "resets" the form to a
"clean" condition. Then after performing the "save", call that method.
The forms initialization logic should call that method also so the
code is not duplicated.

On b), call the desired control's SetFocus method, e.g.
ButtonA.SetFocus.

Quote:
I also have a problem as to how I offer a choice with an Exit button,
i.e. Yes or No. How can I pass control back from the Exit button to the
component which had control before the Exit button was pressed.

That gets much more complicated. Let's assume the Exit button is
activated by a mouse click. The button receives the focus at the time
it receives the mouse down message. But it does not get activated at
that point - the OnClick event does not fire until the mouse up
message is seen. (And if the mouse is moved outside the Exit button
before being released, the button won't be activated or "clicked" at
all, although it will keep the focus.) You can solve this by using
messages and watching for focus changes, but there is no easy
solution.

Quote:
I am sure the solutions to these problems are obvious and simple

This is Windows. There are no obvious, much less simple, solutions<g>.
Good luck.

Kurt


Back to top
Graham A Welsh
Guest





PostPosted: Sun Oct 26, 2003 1:03 pm    Post subject: Re: Newbie Question about moving control/focus Reply with quote

Thanks to Jon & Kurt for their answers. I will be investigating the
possibilities suggested.

--
Graham A Welsh
Targeted Software Solutions Ltd

To Reply: Change "limited" to "ltd" in email address
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.