Page 1 of 1

Receive callback messages in main loop

Posted: Sat Mar 19, 2011 2:36 am
by MachineCode
I wish a future release could let us receive event messages like #WM_QUERYENDSESSION in our main loop instead of having to code a callback to receive them. Thank you.

Re: Receive callback messages in main loop

Posted: Sat Mar 19, 2011 3:33 am
by netmaestro
MSDN for WM_QUERYENDSESSION wrote:Return Values
If an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE.
How were you planning to do this from the main loop, just curious? :wink:

Much of the more advanced functionality of the Windows OS is accomplished in the callback model; the Purebasic main loop can only insulate the coder from the simpler elements and this is why Fred implemented the SetWindowCallback function. Coders of all levels can both achieve rapid success and conquer more in-depth challenges within the one development tool. It's one of the reasons we love it so.

Re: Receive callback messages in main loop

Posted: Sat Mar 19, 2011 4:03 am
by MachineCode
netmaestro wrote:How were you planning to do this from the main loop, just curious? :wink:
I was just hoping something like this could be done:

Code: Select all

If OpenWindow(0,100,150,450,200,"Windows shutdown detect",#PB_Window_SystemMenu)

   Repeat

    eventID=WaitWindowEvent()

    If eventID = #WM_QUERYENDSESSION
      ;Do your stuff here
      MessageRequester("","Oops! Windows are shuting down!!")
    EndIf

   Until eventID=#PB_Event_CloseWindow

EndIf
netmaestro wrote:the Purebasic main loop can only insulate the coder from the simpler elements
I guess my request, then, is: remove that insulation? :)

Re: Receive callback messages in main loop

Posted: Sat Mar 19, 2011 4:09 am
by netmaestro
Well, that's five wasted minutes I'm not getting back.

Re: Receive callback messages in main loop

Posted: Sat Mar 19, 2011 4:16 am
by MachineCode
What does that mean?