It is currently Thu Jun 20, 2013 3:17 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Windows TaskBar info
PostPosted: Thu Mar 15, 2012 4:35 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
While adding the Snap to Window Height, I wanted to make the Task Bar height system-aware, rather than a constant. I came across this post on c#, so I converted some of its functionality to PB, but in two procs.
http://www.pcreview.co.uk/forums/taskba ... 87688.html

Right now, I used two procs for the two return values, and I left in all of the debug info. I hope someone can appreciate it.

Also, if anybody has a Linux or Mac version, that would be great.

PB code:
Code:
;  Enum ABMsg
Enumeration
   #ABM_NEW = 0
   #ABM_REMOVE = 1
   #ABM_QUERYPOS = 2
   #ABM_SETPOS = 3
   #ABM_GETSTATE = 4
   #ABM_GETTASKBARPOS = 5
   #ABM_ACTIVATE = 6
   #ABM_GETAUTOHIDEBAR = 7
   #ABM_SETAUTOHIDEBAR = 8
   #ABM_WINDOWPOSCHANGED = 9
   #ABM_SETSTATE = 10
EndEnumeration


;  Enum ABEdge
Enumeration
   #ABE_LEFT = 0
   #ABE_TOP
   #ABE_RIGHT
   #ABE_BOTTOM
EndEnumeration

;  Enum ABState
Enumeration
   #ABS_MANUAL = 0
   #ABS_AUTOHIDE = 1
   #ABS_ALWAYSONTOP = 2
   #ABS_AUTOHIDEANDONTOP = 3
EndEnumeration

;  Enum TaskBarEdge
Enumeration
   #Bottom
   #Top
   #Left
   #Right
EndEnumeration


Procedure.i GetTaskBarHeight()
   abd.APPBARDATA   ;APPBARDATA abd = new APPBARDATA();
   
   height = 0
   taskBarEdge = #Bottom
   
   ; TaskBarEdge & Height
   SHAppBarMessage_(#ABM_GETTASKBARPOS, abd)
   Select (abd\uEdge)
         Case #ABE_BOTTOM:
               Debug "Taskbar on bottom."
               Debug "bottom=" + Str(abd\rc\bottom) + ", top=" +Str(abd\rc\top)
               taskBarEdge = #Bottom
               height = abd\rc\bottom - abd\rc\top
         Case #ABE_TOP:
               Debug "Taskbar on top."
               Debug "bottom=" + Str(abd\rc\bottom) + ", top= NA"
               taskBarEdge = #Top
               height = abd\rc\bottom
         Case #ABE_LEFT:
               Debug "Taskbar on left."
               Debug "right=" + Str(abd\rc\right) + ", left=" +Str(abd\rc\left)
               taskBarEdge = #Left;
               height = abd\rc\right - abd\rc\left
         Case #ABE_RIGHT:
               Debug "Taskbar on right."
               Debug "right=" + Str(abd\rc\right) + ", left=" +Str(abd\rc\left)
               taskBarEdge = #Right
               height = abd\rc\right - abd\rc\left
   EndSelect
   Debug "hgt = " + Str(height)
   ProcedureReturn height
EndProcedure

Procedure.i GetTaskBarAutoHide()
      
   autoHide = false
   ; TaskBar AutoHide Property
   abd.APPBARDATA   ;abd = new APPBARDATA();
   uState.i = SHAppBarMessage_(#ABM_GETSTATE, abd);
   Select (uState)
         Case #ABS_ALWAYSONTOP:
               autoHide = #False
         Case #ABS_AUTOHIDE:
               autoHide = #True
         Case #ABS_AUTOHIDEANDONTOP:
               autoHide = #True
         Case #ABS_MANUAL:
               autoHide = #False
   EndSelect
   
   Debug "autohide = " + Str(autoHide)
   ProcedureReturn autoHide
EndProcedure


Debug "height return value: " + Str(GetTaskBarHeight())
Debug "AutoHide return value: " + Str(GetTaskBarAutoHide())


Top
 Profile  
 
 Post subject: Re: Windows TaskBar info
PostPosted: Sun Mar 25, 2012 7:01 am 
Offline
User
User
User avatar

Joined: Sun Mar 21, 2010 6:59 am
Posts: 27
Location: Denmark
Works nicely. Could come in handy :-)

_________________
AMD FX-8350@4333MHz | 8GB Corsair DDR3-SDRAM@1800Mhz | 7even Ult 64 Bit & Ubuntu 10.4 | PB 5.11 [x86+x64]
Web: rudz.dk


Top
 Profile  
 
 Post subject: Re: Windows TaskBar info
PostPosted: Thu Mar 29, 2012 5:47 pm 
Offline
Addict
Addict

Joined: Sat Dec 31, 2005 5:24 pm
Posts: 2970
Location: Where ya would never look.....
@Tenaja - thanks for posting this, it was very timely because just had an occaision to use something like this.

_________________
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.


Top
 Profile  
 
 Post subject: Re: Windows TaskBar info
PostPosted: Thu Mar 29, 2012 6:54 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
Glad you could use it. Someone might find this one helpful, too; it is a one-call proc that returns all of the data in a structure. Fewer calls, but more typing to use the data. (And slower, if you don't need all of the data.)

Again, this is Windows-only, which I prefer to avoid, but sometimes it is unavoidable. If any Linux or Mac users wish to chip in a conversion, I'd appreciate it.

Code:
Enumeration
   #ABE_LEFT = 0
   #ABE_TOP
   #ABE_RIGHT
   #ABE_BOTTOM
EndEnumeration

;  Enum ABState
Enumeration
   #ABS_MANUAL = 0
   #ABS_AUTOHIDE = 1
   #ABS_ALWAYSONTOP = 2
   #ABS_AUTOHIDEANDONTOP = 3
EndEnumeration

;  Enum TaskBarEdge
Enumeration
   #Bottom
   #Top
   #Left
   #Right
EndEnumeration

Structure TaskBarStruct
   AutoHide.i
   State.i
   Height.i
;    Bottom.i      ;optional to insert...
;    Top.i
;    Left.i
;    Right.i
   Loc.i
EndStructure

; --------------

Procedure.i GetAllTaskBarInfo(*TaskBar.TaskBarStruct)
   
   *TaskBar\AutoHide = false   ;init the "return" value

   ; TaskBar AutoHide Property
   abd.APPBARDATA   ;abd = new APPBARDATA();
   *TaskBar\State = SHAppBarMessage_(#ABM_GETSTATE, abd);
   Select (*TaskBar\State)
         Case #ABS_ALWAYSONTOP:
               *TaskBar\AutoHide = #False
         Case #ABS_AUTOHIDE:
               *TaskBar\AutoHide = #True
         Case #ABS_AUTOHIDEANDONTOP:
               *TaskBar\AutoHide = #True
         Case #ABS_MANUAL:
               *TaskBar\AutoHide = #False
   EndSelect
   
   
   abd.APPBARDATA   ;APPBARDATA abd = new APPBARDATA();
   
   ; Init "return" values
   *TaskBar\Height = 0
   *TaskBar\Loc = #Bottom
   
   ; TaskBar Location & Height
   SHAppBarMessage_(#ABM_GETTASKBARPOS, abd)
   Select (abd\uEdge)
         Case #ABE_BOTTOM:
               *TaskBar\Loc = #Bottom
               *TaskBar\height = abd\rc\bottom - abd\rc\top
         Case #ABE_TOP:
               *TaskBar\Loc = #Top
               *TaskBar\height = abd\rc\bottom
         Case #ABE_LEFT:
               *TaskBar\Loc = #Left
               *TaskBar\height = abd\rc\right - abd\rc\left
         Case #ABE_RIGHT:
               *TaskBar\Loc = #Right
               *TaskBar\height = abd\rc\right - abd\rc\left
   EndSelect
EndProcedure
; --------------

;
; ; Use this to demo it:
; Global TaskBar.TaskBarStruct
;
; GetAllTaskBarInfo(@TaskBar)
;
; Debug "AutoHide return value: " + Str(TaskBar\AutoHide)
; Debug "height return value: " + Str(TaskBar\Height)
; Debug "Location return value: " + Str(TaskBar\Loc)


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: chi and 0 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