Page 1 of 1

[Windows] Processing system messages

Posted: Mon Feb 22, 2016 10:38 am
by Korolev Michael
My app works without GUI.
But sometimes I need to process some system events, for example, WM_QUERYENDSESSION:

Code: Select all

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
  If uMsg = #WM_QUERYENDSESSION
    ...Some code...
  EndIf
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
But for processing system events, I need to create invisible window and process them in window main loop WaitWindowEvent()
Can I make processing of events without invisible window?

Re: [Windows] Processing system messages

Posted: Mon Feb 22, 2016 10:45 am
by RSBasic
You need a window. It is not possible without window.

Re: [Windows] Processing system messages

Posted: Mon Feb 22, 2016 10:46 am
by Korolev Michael
Thanks a lot.

Re: [Windows] Processing system messages

Posted: Mon Feb 22, 2016 11:24 am
by Dude
Korolev Michael wrote:Can I make processing of events without invisible window?
Yep, just make the window visible. :P (Sorry, couldn't resist).

Re: [Windows] Processing system messages

Posted: Mon Feb 22, 2016 11:25 am
by Korolev Michael
Image

Re: [Windows] Processing system messages

Posted: Mon Feb 22, 2016 3:11 pm
by netmaestro
What you want is a message-only window. You can create one easily by creating a PureBasic window and applying SetParent_() to it specifying #HWND_MESSAGE for the parent window handle or with CreateWindowEx if you prefer.

Have a look here: https://msdn.microsoft.com/en-us/librar ... ssage_only

Re: [Windows] Processing system messages

Posted: Mon Feb 22, 2016 3:30 pm
by Korolev Michael
netmaestro, from your link:
[...]and does not receive broadcast messages.[...]
I'm not sure if it fit for me.