FormCloseQuery called by System ShutDown, how to know? lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Shebuka · 2011-07-05 17:21 How can i test/know if my FormCloseQuery is invoked because the user is ShutDown/Reboot the system? I'v looken in NSApplication for ApplicationShouldTerminateNotification, but it's absent and there is only replyToApplicationShouldTerminate which is useless without first one... I need to know it because i have a close mtConfirmation dialog that shows in FormCloseQuery and i wouldn't like to show it if the system is shutting down... ---------------------------------------------------------------------- felipemdc · 2011-07-06 06:13 The usage of replyToApplicationShouldTerminate is explained here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual /AppArchitecture/Tasks/GracefulAppTermination.html But from what I read one can't differentiate with that if the system will shut down because of a restart or a log out or because someone used the force quit button for example. There is some stuff about geting a notification on Sleep here: http://developer.apple.com/library/mac/#qa/qa1340/_index.html One good idea is always searching the cocoa-dev mailling list archives, but I couldn't find anything there on the topic. ---------------------------------------------------------------------- Shebuka · 2011-07-06 06:21 Quote from: felipemdc on July 06, 2011, 08:13:05 amThe usage of replyToApplicationShouldTerminate is explained here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual /AppArchitecture/Tasks/GracefulAppTermination.html I have read that page but in actual lazarus NSApplication there is no ApplicationShouldTerminate, it's absent... ---------------------------------------------------------------------- felipemdc · 2011-07-06 08:16 Quote from: Shebuka on July 06, 2011, 08:21:24 amI have read that page but in actual lazarus NSApplication there is no ApplicationShouldTerminate, it's absent... What is a actual lazarus NSApplication? Where is that declared? Which LCL widgetset are you using? ---------------------------------------------------------------------- Shebuka · 2011-07-06 08:46 NSApplication.inc is included in AppKit.inc wich is included in appkit.pas and where we can find the declaration NSApp: NSApplication; which i actually use to deliver notifications to user by bouncing the dockbar icon (and somewhere on forum i'v explained how to do this). located in interfaces/carbon/pascocoa/appkit/ carbon widget but still i don't know how to catch the ApplicationShouldTerminate Notification... ---------------------------------------------------------------------- Shebuka · 2011-09-16 16:49 Quote from: Shebuka on July 06, 2011, 10:46:56 ambut still i don't know how to catch the ApplicationShouldTerminate Notification... Any ideas of how resolve this? ---------------------------------------------------------------------- User137 · 2011-09-16 19:24 See this thread: http://lazarus.freepascal.org/index.php/topic,11326.msg58597.html#msg5 8597 FormCloseQuery doesn't even execute when system is shutdown. ---------------------------------------------------------------------- Shebuka · 2011-09-19 09:25 Quote from: User137 on September 16, 2011, 09:24:43 pmSee this thread: http://lazarus.freepascal.org/index.php/topic,11326.msg58597.html#msg5 8597 FormCloseQuery doesn't even execute when system is shutdown. On Mac OS X FormCloseQuery is executed when i try to shutdown my system... now i'v tried to add inside .lpr this: Code: [Select]begin   Application.Initialize;   Application.CreateForm(TFrm_Main, Frm_Main);   Application.OnQueryEndSession := @Frm_Main.ApplQueryEndSession;   Application.OnEndSession := @Frm_Main.ApplEndSession;   Application.Run; end. and inside formmain this: Code: [Select]procedure TFrm_Main.ApplQueryEndSession(var Cancel: Boolean); begin     LOG_Fatal('ApplQueryEndSession');     if Frm_Info.Visible then       Frm_Info.Close;     if Frm_Options <> nil then       if Frm_Options.Visible then         Frm_Options.Close; end;and same code for ApplEndSession ApplQueryEndSession is not called ('ApplQueryEndSession' is not logget to log file), neither ApplEndSession, but FormCloseQuery yes, and the mtConfirmation dialog is popped up...