Page 1 of 1

Message-only windows

Posted: Mon Dec 28, 2009 3:15 pm
by netmaestro
On Windows, you can convert any window to an invisible message-only window using SetParent_() after the window is created, but currently v4.40 is giving an error message "Invalid parent handle" if you try to put it in the OpenWindow() command.

Such a window is desirable for applications whose primary communication with the user is a systray icon.

Code snippet shows a window being converted to message-only after 2 seconds using SetParent. It becomes invisible, loses the taskbar icon, and becomes a message pump only:

Code: Select all

#HWND_MESSAGE = -3

OpenWindow(0,0,0,512,512,"Message Window Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) ; try to put it here :(

; wait 2 seconds 
start = ElapsedMilliseconds()
While ElapsedMilliseconds()-start < 2000
  WaitWindowEvent(1)
Wend

SetParent_(WindowID(0), #HWND_MESSAGE)

; wait 2 seconds 
start = ElapsedMilliseconds()
While ElapsedMilliseconds()-start < 2000
  WaitWindowEvent(1)
Wend

Debug "Test finished"

Re: OpenWindow() parent handle param won't accept #HWND_MESSAGE

Posted: Mon Dec 28, 2009 3:36 pm
by freak
If API stuff cannot be used directly with PB commands that is not considered to be a bug.

Re: OpenWindow() parent handle param won't accept #HWND_MESSAGE

Posted: Mon Dec 28, 2009 4:00 pm
by netmaestro
Ok. Could someone please move this to Feature requests then as #PB_Window_MessageOnly seems useful.

Re: Message-only windows

Posted: Mon Dec 28, 2009 8:35 pm
by DoubleDutch
+1 I think they would be pretty useful too.

Re: Message-only windows

Posted: Mon Dec 28, 2009 8:43 pm
by freak
Well, this is a Windows-only concept. Whats wrong with using an invisible window btw ?

Re: Message-only windows

Posted: Mon Dec 28, 2009 10:05 pm
by netmaestro
Whats wrong with using an invisible window btw ?
An invisible window won't process hotkey messages. If you want a systray app with no main window you have to make the window 0 and 0 for width and height, borderless and show it in order to respond to hotkeys. (afaik, pls correct me if I'm wrong). However, with a message-only window you get a solution that's clean and designed for the purpose. Please consider implementing on Windows if the other OS's don't support it.

Re: Message-only windows

Posted: Tue Dec 29, 2009 12:15 am
by UserOfPure
netmaestro wrote:An invisible window won't process hotkey messages.
That's news to my app. It processes hotkey messages just fine, even though it's set to #SW_HIDE most of the time.

Re: Message-only windows

Posted: Sat Jan 02, 2010 4:55 am
by netmaestro
UserofPure wrote:That's news to my app
I'm glad to hear it. Of course, it all depends on which type of hotkey you're using.