Recent

Author Topic: RichMemo - OnChange triggered on close - why that?  (Read 1174 times)

Nicole

  • Hero Member
  • *****
  • Posts: 970
RichMemo - OnChange triggered on close - why that?
« on: August 06, 2022, 10:09:30 am »
The user shall not close the app and loose his changes in TRichMemo. So I made a check for changes. Unfortunately this check is triggered if changed and IF NOT as well.


The idea:
OnCreate the file of the last session is loaded by

Code: Pascal  [Select][+][-]
  1.   RichMemoName:=RichEdit_File;
  2.   LoadRTFFile(RichMemo_Notizen, RichMemoName);
  3.   Saved_RichMemo:=true;

of close, I ask for this "saved_RichMemo".

The problem:
The parameter saved_RichMemo is every close FALSE, although I did not change anything.

So I had a closer look at thie onChange and it reads:

Code: Pascal  [Select][+][-]
  1.  showMessage('I am triggered!!');
  2.  Saved_RichMemo:=False;
  3.  

I did this
- started the app
- NOT TOUCHED my Richmemo
- close the app

I saw the "I am triggered"-message by closing the app.

How can I make my app stop asking stupid questions?
or in other words: If my RichMemo is loaded and not edited, the app shall close without saved-check.
Thanks.


paweld

  • Hero Member
  • *****
  • Posts: 970
Re: RichMemo - OnChange triggered on close - why that?
« Reply #1 on: August 06, 2022, 01:44:12 pm »
sample in attachment
Best regards / Pozdrawiam
paweld

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: RichMemo - OnChange triggered on close - why that?
« Reply #2 on: August 06, 2022, 01:58:56 pm »
Thank you for the project.

"FormShow" is the main difference between your project and mine. I did the loading in the create event.

I am new to Lazarus (coming from an old Delphi).
Do you have more information about this "FormShow"? I am afraid, I never heard "FromShow" before and google did not really explain it in short.

AlexTP

  • Hero Member
  • *****
  • Posts: 2389
    • UVviewsoft
Re: RichMemo - OnChange triggered on close - why that?
« Reply #3 on: August 06, 2022, 03:14:28 pm »
FormShow is the handler for TForm.OnShow.

AlexTP

  • Hero Member
  • *****
  • Posts: 2389
    • UVviewsoft
Re: RichMemo - OnChange triggered on close - why that?
« Reply #4 on: August 06, 2022, 03:29:02 pm »
I got the paweld's sample, added there RichMemo1.OnChange handler, it is NOT called on closing the app. I don't see a problem.

Nicole

  • Hero Member
  • *****
  • Posts: 970
[solved] RichMemo - OnChange triggered on close - why that?
« Reply #5 on: August 06, 2022, 03:50:09 pm »
... sorry for having bothered you and thank you for the ideas.

I found the mistake,  >:D

- I had loaded it twice by mistake.
The first loading the var was set to "saved", the second loading was just a lost line, which triggered the OnChange event, which is not really surprising once you found it.

 

TinyPortal © 2005-2018