Message-only windows

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Message-only windows

Post 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"
Last edited by netmaestro on Mon Dec 28, 2009 5:22 pm, edited 1 time in total.
BERESHEIT
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

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

Post by freak »

If API stuff cannot be used directly with PB commands that is not considered to be a bug.
quidquid Latine dictum sit altum videtur
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

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

Post by netmaestro »

Ok. Could someone please move this to Feature requests then as #PB_Window_MessageOnly seems useful.
BERESHEIT
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Message-only windows

Post by DoubleDutch »

+1 I think they would be pretty useful too.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Message-only windows

Post by freak »

Well, this is a Windows-only concept. Whats wrong with using an invisible window btw ?
quidquid Latine dictum sit altum videtur
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Message-only windows

Post 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.
BERESHEIT
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Re: Message-only windows

Post 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Message-only windows

Post 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.
BERESHEIT
Post Reply