Re: API for TaskBar options

From: keepITcool (xrrcvgpbby_at_puryyb.ay)
Date: 07/17/04


Date: Sat, 17 Jul 2004 11:05:20 -0700

Adam..

ApiViewer and ApiGuide do not mention the ABM_SETSTATE constant
nevertheless it works.. in WINDOWS XP only

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/shellcc/platform/shell/reference/messages/abm_setstate.asp

Although toggling thru the settings is quite useless it DOES demonstrate
how to set the options AutoHide and AlwaysOnTop <vbg>

Option Explicit

Private Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type
Private Type APPBARDATA
  cbSize As Long
  hwnd As Long
  uCallbackMessage As Long
  uEdge As Long
  rc As RECT
  lParam As Long
End Type

Const ABS_AUTOHIDE As Long = &H1
Const ABS_ALWAYSONTOP As Long = &H2
Const ABM_GETSTATE As Long = &H4
Const ABM_GETTASKBARPOS As Long = &H5
Const ABM_SETSTATE As Long = &HA

Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal
dwMessage As Long, pData As APPBARDATA) As Long

Sub TaskBarToggle()
' keepITcool excel.programming 17-jul-2004
  Dim BarData As APPBARDATA, Ret As Long
  
  'Prep buffer
  BarData.cbSize = Len(BarData)
  
  'Fill structure
  Call SHAppBarMessage(ABM_GETTASKBARPOS, BarData)
  'get state
  Ret = SHAppBarMessage(ABM_GETSTATE, BarData)
  Debug.Print "Before:", (Ret And ABS_AUTOHIDE), _
     (Ret And ABS_ALWAYSONTOP)
  'set lParam
  BarData.lParam = Ret Mod 3 + 1
  'notify system
  Ret = SHAppBarMessage(ABM_SETSTATE, BarData)
  'read back
  Ret = SHAppBarMessage(ABM_GETSTATE, BarData)
  Debug.Print "After :", (Ret And ABS_AUTOHIDE), _
     (Ret And ABS_ALWAYSONTOP)
  Debug.Print
End Sub

keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >

adam99 <<adam99.19j033@excelforum-nospam.com>> wrote:

> Hi All,
>
> Can someone help me with the Windows task bar. I am trying to turn off
> "Keep task bar on top" option. I have found an API that gets the state
> of the taskbar but I cannot seem to set it.
> Declare Function SHAppBarMessage Lib "shell32.dll" _
> (ByVal dwMessage As Long, pData As APPBARDATA) As Long
>
> Does anyone know how to set this property?
> The only information I have found that it can only be set for Windows
> 2000 which in my case would be fine.
> I need to turn this option off before I change the resolution of
> computers running Windows 2000 as it causes the whole taskbar to be
> placed in the middle of the screen.
>
> Thanks,
> Adam.
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>