Forum > RichMemo

RichMemo - OnChange triggered on close - why that?

(1/2) > >>

Nicole:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  RichMemoName:=RichEdit_File;  LoadRTFFile(RichMemo_Notizen, RichMemoName);   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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- showMessage('I am triggered!!'); Saved_RichMemo:=False; 
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:
sample in attachment

Nicole:
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:
FormShow is the handler for TForm.OnShow.

AlexTP:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version