Receive callback messages in main loop

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Receive callback messages in main loop

Post 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.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Receive callback messages in main loop

Post 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.
BERESHEIT
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Receive callback messages in main loop

Post 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? :)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Receive callback messages in main loop

Post by netmaestro »

Well, that's five wasted minutes I'm not getting back.
BERESHEIT
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Receive callback messages in main loop

Post by MachineCode »

What does that mean?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply