Exception if "Application.Terminate" is called in ...FormCreate lazarus / 31-LCL ---------------------------------------------------------------------- hs40470 · 2024-08-12 19:28 If an application detects that it is not able to start because of "something" is missing (in my case a special app-specific font installed) and try to stop running the app by calling "Application.Terminate" in (any) ...FormCreate callback "TApplication.Run" will be still called and it execution will cause an exception. I modified "TApplication.Run" by adding 3 lines, so it's now: procedure TApplication.Run; begin   if not Terminated then // <-- THIS IS ADDED   begin     if (FMainForm <> nil) and FShowMainForm then     begin       WidgetSet.AppSetupMainForm(FMainForm);       FMainForm.Show;     end;     WidgetSet.AppRun(@RunLoop);   end; end; The additional line solves the problem without modifing any project specific code. Here is a snippet of my app source (sorry for the german message text): procedure TMainForm.FormCreate(Sender: TObject); var     lStp: boolean; begin   lStp := Screen.Fonts.IndexOf(TM_FontName) < 0;   try     if lStp then       ShowMsgDlg(CreateMessageDialog('Die benötigte Schriftart "' + TM_FontName +                                      '" ist nicht'#13#10'installiert: ' +                                      'Das Programm muss deshalb beendet werden',                                      mtCustom, [mbOK]))     else     begin ... ... ...     end;   finally     if lStp then       Application.Terminate();   end; end; ---------------------------------------------------------------------- ASerge · 2024-08-12 20:28 Simplified example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  Dlg: TForm;begin  Dlg := CreateMessageDialog('Test', 'Test', mtCustom, [mbOk]);  try    Dlg.ShowModal;  finally    Dlg.Free;    Application.Terminate;  end;end;Windows x64. Lazarus 3.4. No Error. Maybe there is an error in the unknown ShowMsgDlg procedure? ---------------------------------------------------------------------- Joanna · 2024-08-21 07:16 @ hs40470 Have you ever considered using code tags ? Or Do you prefer the spacious  copy paste look ?