Link to home
Start Free TrialLog in
Avatar of Ron_de_Weijze
Ron_de_Weijze

asked on

OnExit special processing when switching between forms

Hello expert!

From the VCL reference help:

"Use the OnExit event handler to provide special processing when the control ceases to be active.

The OnExit event does not occur when switching between forms or between another application and your application."

What I need is this special processing when switching between forms.

The FormDeactivate event notices the switch, but what method evokes the OnExit special processing? I need it to save text in a RichEdit that disappears when switching forms. When I use the tab-key to jump (change focus?) from the RichEdit to a different control first and then switch forms, the text does not get lost.

I do not want to use a file and a button, only want to keep the text in the RichEdit as if the tab-key was hit just before the switch.

Any ideas?

Thanks
Ron dW
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

you can call the OnExit event manually

e.g.
procedure TForm1.FormDeactivate(Sender: TObject);
begin
    Form1.RichEdit1OnExit(Form1.RichEdit1); // or you can use (nil) if you do not use "sender" in your onexit code
end;

Avatar of Ron_de_Weijze
Ron_de_Weijze

ASKER

Thanks TheRealLoki,

Now I can get to the OnExit event, but which call(s) save the text that is in the RichEdit and that is only kept (automatically) if the tab-key is hit?
Again, in other words:

Hitting the tab-key after text was put into the RichEdit, moves the cursor to the next control on the same form, thereby processing the text in the RichEdit somehow automatically, so that it does *not* get lost after the form is left, by clicking on another form on the screen. The events, FormDeactivate and RichEdit1OnExit, can be trapped to put in the right code but what is that code that preserves the text in the RichEdit and that is executed when tabbing from the RichEdit to the next control on the form, but that is not executed when clicking on a different form without explicit saving?
Apparently no-one knows, or I did not phrase the question well enough. (Or I am just plain stupid.)
This ticket can be closed. I will try again later with a new one, when I hit the same problem again.

Ron dW
ASKER CERTIFIED SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Loki,

Sorry for responding so late. I need to find time to get back to the situation. ASAP.

Regards,
Ron dW