Page 1 of 1

Event add #WM_ENDSESSION for save() etc.

Posted: Fri Apr 07, 2017 12:57 pm
by gurj
Event add #WM_ENDSESSION for save() etc.

Re: Event add #WM_ENDSESSION for save() etc.

Posted: Fri Apr 07, 2017 11:27 pm
by gurj
If system closing And If our program Not got Case #WM_ENDSESSION
our program will killed tough
so,from winapi_library of RSBasic:
(see code)
but I Not hope my code in this Procedure, so hope pb_Event has own 'Case #WM_ENDSESSION'
thanks!

Code: Select all

EnableExplicit

Define EventID

Procedure WinCallback(hWnd, uMsg, wParam, lParam) 
 If uMsg = #WM_ENDSESSION 
  ;(my code)
    ;Windows wird heruntergefahren.
    ;Hier ké°Šnen noch wichtige Einstellungen gespeichert werden.
  EndIf 

  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowCallback(@WinCallback())
  
  Repeat
    EventID = WaitWindowEvent()
    If EventID = #PB_Event_CloseWindow
      End
    EndIf
  ForEver
EndIf