[Windows] Processing system messages

Just starting out? Need help? Post your questions and find answers here.
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

[Windows] Processing system messages

Post 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?
Former user of pirated PB.
Now registered user :].
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: [Windows] Processing system messages

Post by RSBasic »

You need a window. It is not possible without window.
Image
Image
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: [Windows] Processing system messages

Post by Korolev Michael »

Thanks a lot.
Former user of pirated PB.
Now registered user :].
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: [Windows] Processing system messages

Post 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).
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: [Windows] Processing system messages

Post by Korolev Michael »

Image
Former user of pirated PB.
Now registered user :].
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: [Windows] Processing system messages

Post 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
BERESHEIT
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: [Windows] Processing system messages

Post by Korolev Michael »

netmaestro, from your link:
[...]and does not receive broadcast messages.[...]
I'm not sure if it fit for me.
Former user of pirated PB.
Now registered user :].
Post Reply