[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

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
0
Ron_de_Weijze
Asked:
Ron_de_Weijze
  • 4
  • 2
1 Solution
 
TheRealLokiSenior DeveloperCommented:
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;

0
 
Ron_de_WeijzeAuthor Commented:
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?
0
 
Ron_de_WeijzeAuthor Commented:
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?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ron_de_WeijzeAuthor Commented:
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
0
 
TheRealLokiSenior DeveloperCommented:
Sorry, this is the best I can come up with atm.
I did do a thorough test, and saw what you mean. No OnExit event, so you do not get a chance to save
However, if you use the current form's OnDeactivate event, it is better, and does not matter which other form you click on
e.g.

procedure TForm1.RichEdit1Exit(Sender: TObject);
    begin
        if RichEdit1.Modified then  SaveRichEditChanges;
    end;

procedure TForm1.FormDeactivate(Sender: TObject);
    begin
        if RichEdit1.Modified then SaveRichEditChanges;
    end;

procedure TForm1.SaveRichEditChanges;
    begin
        // Do any processing here (e.g. RichEdit1.Lines.SaveToFile)
        RichEdit1.Modified := False;
    end;

I am not sure what you mean by the RichEdit's "special processing" - Let me know, and I will look into this more
0
 
Ron_de_WeijzeAuthor Commented:
Loki,

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

Regards,
Ron dW
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now