Forum > Packages and Libraries
Something wrong when i close app access violation error
eldonfsr:
I tried different ways to solve this problem i don't know why send me access error violation
just open and click on close or event if type information on EditDirectory fiels .....
eldonfsr:
Could be OnClose Event can't execute many instructions or commands just i made change only on
close event and works..
--- 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";}};} ---procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);begin BDConf.SaveToFile(GetCurrentdir+'\config.dat',dfBinary);end;
cdbc:
Hi
In the OnClose-event there's a CloseAction variable, that you need to set...:
--- 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";}};} ---procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);begin BDConf.SaveToFile(GetCurrentdir+'\config.dat',dfBinary); { when you're done with your stuff, tell the FormMain, it's ok to close/free } CloseAction:= caFree; { ...or e.g.: caHide }end; Regards Benny
TRon:
1. You create a leak with TLog:= TMemo.Create(nil);
2. Use DirectorySeparator instead of GetCurrentdir+'\config.dat'
3. using the formshow event to initialize your stuff is a bad habbit. It is done everytime the form is shown (so also every time a user 'activates' your application in order to show the main form).
4. The configuration file you saved can not be read again (stream read error)
Sorry as I did not try to locate your original issue.
tetrastes:
--- Quote from: TRon on June 06, 2023, 08:04:59 am ---3. using the formshow event to initialize your stuff is a bad habbit. It is done everytime the form is shown (so also every time a user 'activates' your application in order to show the main form).
--- End quote ---
Are you sure? May be I don't understand something, but...
Create the simplest app with form and OnShow event:
--- 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";}};} ---procedure TForm1.FormShow(Sender: TObject);begin ShowMessage('FormShow is called');end;Message window is shown only once, when you start the app, whatever you do with it later (resize, minimize, bring to back under other window, bring to front...), message is not shown again.
Navigation
[0] Message Index
[#] Next page