It is currently Mon Aug 19, 2019 9:35 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Tip: ToolWindow (tiny code version)
PostPosted: Tue Jan 21, 2003 3:27 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Code updated For 5.20+

Restored from previous forum. Originally posted by PB.

Opens a window without a button for it in the Taskbar.

Various versions of this have already been posted, but some use ASM,
and some use very long API routines with CreateWindowEx, etc... this
is simple, compact and neat. Thanks to vanleth and Bericko for helping.

Code:
; MENULESS VERSION -- Requires ResizeWindow as a result.
WinW=400 : WinH=200
If OpenWindow(0,200,200,WinW-1,WinH-1,"ToolWindow",#PB_Window_Invisible|#PB_Window_SystemMenu)
  SetWindowLong_(WindowID(0),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW)
  ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_SHOW)
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf

Code:
; MENU VERSION -- Create your menu before showing the window!
If OpenWindow(0,200,200,400,200,"ToolWindow",#PB_Window_Invisible|#PB_Window_SystemMenu)
  SetWindowLong_(WindowID(0),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW)
  ; Define your menus here!
  ShowWindow_(WindowID(0),#SW_SHOW)
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 21, 2003 3:49 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by vanleth.

Holy cow, Excellent Approach

Van


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 21, 2003 8:17 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Berikco.

A resizewindow will also remove the glitch.
It believe it was posted before, but i can't find it...
Code:
If OpenWindow(0,200,200,399,199,#PB_Window_Invisible|#PB_Window_SystemMenu,"ToolWindow")
  SetWindowLong_(WindowID(),#GWL_EXSTYLE,GetWindowLong_(WindowID(),#GWL_EXSTYLE)!#WS_EX_TOOLWINDOW)
  ResizeWindow(400, 200) : ShowWindow_(WindowID(),#SW_SHOW)
  Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow
EndIf


Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 21, 2003 10:58 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by PB.

> A resizewindow will also remove the glitch.

Thanks for that... it'll use less resources (I assume) due to not
having an unused menu.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 21, 2003 11:35 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Berikco.

Quote:
Originally posted by PB
it'll use less resources (I assume) due to not
having an unused menu.


yep :)

Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 21, 2003 5:42 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by Franco.

Dumb question:
Why is before #WS_EX_TOOLWINDOW the "!" :)
I thought there should be a "|".

Both method are working though.

Have a nice day...

Franco


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 21, 2003 10:21 pm 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by fred.

True, the '!' is wrong here, an | is more correct.

Fred - AlphaSND


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jan 22, 2003 1:02 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by PB.

> True, the '!' is wrong here, an | is more correct.

I got the code snippet from a VB source originally, which used Xor in
the code, and in PureBasic, the ! character is used for Xor, so that's
why I used it.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jan 22, 2003 8:59 am 
Offline
PureBasic Guru
PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777133
Restored from previous forum. Originally posted by fred.

VB source was wrong :).

Fred - AlphaSND


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 31, 2005 2:17 pm 
Offline
Always Here
Always Here

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7439
Location: Norway
You can also set a parent window if you have one. This will make the child window's button disappear.

Creation:
Code:
OpenWindow(... WindowID(#MainWindow)


Runtime:
Code:
SetParent_(WindowID(), WindowID(#MainWindow))


Edit: just realized this topic was about making a tool window. Why does the FAQ entry "How do I stop my app's window showing in the TaskBar?" lead here?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 31, 2005 2:37 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 16, 2003 3:47 pm
Posts: 1310
Location: England
Because tool windows don't appear in the taskbar.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 31, 2005 8:03 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Fri Apr 25, 2003 5:24 pm
Posts: 7581
> Why does the FAQ entry "How do I stop my app's window showing in the
> TaskBar?" lead here?

Because that's what a newbie is more likely to ask when they don't want
their app to show in the Taskbar. ;)

_________________
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 31, 2005 9:43 pm 
Offline
Always Here
Always Here

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7439
Location: Norway
But what if you want a NORMAL window which doesn't show in the taskbar?

Edit: To those who came here for that, here is how:
Code:
OpenWindow(1, 0, 0, 0, 0, #PB_Window_Invisible, "Parent")
OpenWindow(0,0,0,222,200,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"App without taskbar button", WindowID())
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Nov 04, 2005 4:58 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
Nice trick there Trond!
And by the looks of it, there appears to be no significant change in the memory usage either.
(to test this comment the first open window line)
Heh, here is seemed the extra window trick actualy uses a few KB less memory. :shock:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Nov 04, 2005 8:45 am 
Offline
Always Here
Always Here

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7439
Location: Norway
Rescator wrote:
Heh, here is seemed the extra window trick actualy uses a few KB less memory. :shock:
Yes you are right. That's very strange.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye