Problem with WS_EX_TOOLWINDOW

Just starting out? Need help? Post your questions and find answers here.
Chirantha
User
User
Posts: 54
Joined: Sat Jul 16, 2005 7:22 pm

Problem with WS_EX_TOOLWINDOW

Post by Chirantha »

Hi,

I'm creating a window with the WS_EX_TOOLWINDOW flag. Here is the code

Code: Select all

OpenWindow(0,0,0,320,240,"Window",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
HideWindow(0,1)
SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) 
HideWindow(0,0)
If CreateGadgetList(WindowID(0))
  ButtonGadget(1, 60, 60, 60, 20, "blub")
EndIf

Repeat
WaitWindowEvent()
Delay(20)
ForEver
The window creates just fine but when I minimize the background window aka the window just behind my window. My window gets sent to the back of the previous window (it doesn't get forcus, nor can I bring it up with the ALT+TAB buttons). I believe this is not the behaviour of a normal window.

How do I fix it, all I wanted to do was to remove the app from the taskbar :(
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

regarding your "cant close" problem... you are not handling the window's events, hence, you cannot close the window, ever.

try this:

Code: Select all

If OpenWindow(0,0,0,320,240,"Window",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
	
	HideWindow(0,1)
	SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_TOOLWINDOW)
	HideWindow(0,0)
	
	If CreateGadgetList(WindowID(0))
	  ButtonGadget(1, 60, 60, 60, 20, "blub")
	EndIf
	
	Repeat
	    EventID = WaitWindowEvent()
	    Select EventID
	    	Case #PB_Event_CloseWindow
	      	Quit = 1
	    EndSelect
	Until Quit = 1
	
EndIf
WaitWindowEvent() already "waits" so there is NO need to add a Delay(), you can add a timeout value to WaitWindowEvent() though.

:lol: should I bash the keyboard and give up?
:?
Chirantha
User
User
Posts: 54
Joined: Sat Jul 16, 2005 7:22 pm

Post by Chirantha »

superadnim wrote:regarding your "cant close" problem... you are not handling the window's events, hence, you cannot close the window, ever.

try this:

Code: Select all

If OpenWindow(0,0,0,320,240,"Window",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
	
	HideWindow(0,1)
	SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_TOOLWINDOW)
	HideWindow(0,0)
	
	If CreateGadgetList(WindowID(0))
	  ButtonGadget(1, 60, 60, 60, 20, "blub")
	EndIf
	
	Repeat
	    EventID = WaitWindowEvent()
	    Select EventID
	    	Case #PB_Event_CloseWindow
	      	Quit = 1
	    EndSelect
	Until Quit = 1
	
EndIf
WaitWindowEvent() already "waits" so there is NO need to add a Delay(), you can add a timeout value to WaitWindowEvent() though.
Have you read my post correctly? you are totally off topic here :S
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Chirantha wrote:Have you read my post correctly? you are totally off topic here :S
He's totally ontopic, why you use Delay() with WaitWindowEvent()?
Chirantha wrote:I believe this is not the behaviour of a normal window.
In fact the behaviour is perfectly normal since you hide the window from the taskbar. So the question is what are you trying to achieve here? Is this is going to be some sort of systray application?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Chirantha
User
User
Posts: 54
Joined: Sat Jul 16, 2005 7:22 pm

Post by Chirantha »

Fluid Byte wrote:
Chirantha wrote:Have you read my post correctly? you are totally off topic here :S
He's totally ontopic, why you use Delay() with WaitWindowEvent()?
Chirantha wrote:I believe this is not the behaviour of a normal window.
In fact the behaviour is perfectly normal since you hide the window from the taskbar. So the question is what are you trying to achieve here? Is this is going to be some sort of systray application?
1. launch some apps and maximie them and then launch pb.... (don't minimize them)
2. run this code
3. now minimize pb window or some other window..
now see that the app disappears... you won't be able to see app until you minimize all apps!
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Chirantha wrote:The window creates just fine but when I minimize the background window aka the window just behind my window. My window gets sent to the back of the previous window (it doesn't get forcus, nor can I bring it up with the ALT+TAB buttons). I believe this is not the behaviour of a normal window.
Once you add the #WS_EX_TOOLWINDOW you are no longer dealing with a normal window. The behavior you describe is correct for a Toolwindow.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

usually, a tool has a parent.
a correct and complete eventhandling would also help.

Code: Select all

If OpenWindow(0,320,240,320,240,"Parent" ) 
  If OpenWindow(1,0,0,320,240,"ToolWindow", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget, WindowID(0))
    HideWindow(1,1)
    SetWindowLong_(WindowID(1),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_TOOLWINDOW)
    HideWindow(1,0)
    If CreateGadgetList(WindowID(0))
      ButtonGadget(0, 60, 60, 60, 20, "blub")
    EndIf
    Repeat
       EventID = WaitWindowEvent()
       EventWin = EventWindow()
       EventGad = EventGadget()
       Select EventID
          Case #PB_Event_Gadget
            Select EventGad
              Case 0
                HideWindow(1,0)
            EndSelect
          Case #PB_Event_CloseWindow
            Select EventWin
              Case 0
                Quit = 1
              Case 1
                HideWindow(1,1)
            EndSelect
       EndSelect
    Until Quit = 1
  EndIf
EndIf
oh... and have a nice day.
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Re: Problem with WS_EX_TOOLWINDOW

Post by Seldon »

Code: Select all

SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) 
After you change a normal window into a toolwindow, I do suggest to resize its width and height as there could be some weird problems with the window drawing on systems with no GUI themes set, like Windows 2000 .

Code: Select all

ResizeWindow(0,#PB_Ignore,#PB_Ignore,WindowWidth(0)+1,WindowHeight(0)+1)
Another suggestion is to open the window as 'hidden' and show it after you've changed its attributes. Not in topic, but some good tips I think. :)
Post Reply