Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Controlling the windows taskbar from VBA (API example)

I found this code on another post and it works perfectly... however (see below)

Private Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal
nCmdShow&)

Sub TaskBar_Hide()
ShowWindow FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString), 0
End Sub

Sub TaskBar_Show()
ShowWindow FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString), 5
End Sub

However,
This seems to be setting a visible flag for the task bar. What I need is to
activate/deactivate the minimize of the task bar. (When you position the
mouse on the top line of the task bar, you get a double-headed arrow. when
you click-drag down, it minimizes the task bar. This leaves a small line
which is the top of the task bar that you can grab and drag up to un-minimize
the task bar).

How do I access that feature from VBA (using API or not)

I need this so that when I set my spreadsheet to show fullscreen, the status
bar gets hidden under the taskbar (becuse I want to leave it set "always on
top") I have found that manually minimizing then maximizing the taskbar
forces the status bar to show (I.E. the spreadsheet's full screen becomes
limited at the bottom to force both the taskbar and the (excel) statusbar to
be both visible.)

Also Im curious what the & in the above "FindWindowEx&" API call code does.
The code stops working when that character is removed.

--
Regards,
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Controlling the windows taskbar from VBA (API example)

Hi John,
The & is the symbol of a Long type of variable
The $ is the symbol of a String type of variable

To show fullscreen, change the work area like this:

Option Explicit
Private Declare Function SystemParametersInfoA& _
Lib "user32" (ByVal uAction&, ByVal uParam& _
, lpvParam As Any, ByVal fuWinIni&)
Private Declare Function GetWindowRect& Lib _
"user32" (ByVal hwnd&, lpRect As RECT)
Private Declare Function FindWindowA& Lib _
"user32" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function ShowWindow& Lib _
"user32" (ByVal hwnd&, ByVal nCmdShow&)

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private hwnd&, Desktop As RECT

' Warning: this may reorder desktop icons
Sub TaskBar_Hide()
Application.ScreenUpdating = False
Dim TaskBar As RECT
hwnd = FindWindowA("Shell_traywnd", "")
' Get TaskBar area
GetWindowRect hwnd, TaskBar
' Get Desktop area
SystemParametersInfoA 48, 0&, Desktop, 0&
' Set Full screen area and hide TaskBar
TaskBar.Bottom = (TaskBar.Bottom - TaskBar.Top) _
+ (Desktop.Bottom - Desktop.Top)
TaskBar.Top = Desktop.Top
TaskBar.Left = Desktop.Left
TaskBar.Right = Desktop.Right
ShowWindow hwnd, 0
SystemParametersInfoA 47, 0, TaskBar, 0
AppActivate Application.Caption
Application.WindowState = xlNormal
Application.WindowState = xlMaximized
End Sub

Sub TaskBar_Show()
Application.ScreenUpdating = False
' Restore desktop area
SystemParametersInfoA 47, 0, Desktop, 0
' Show TaskBar
ShowWindow hwnd, 8
Application.WindowState = xlNormal
Application.WindowState = xlMaximized
End Sub

Regards,
MP

"John Keith" a écrit dans le message
de news: ...
I found this code on another post and it works perfectly... however (see

below)

Private Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA"

_
(ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal
nCmdShow&)

Sub TaskBar_Hide()
ShowWindow FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString), 0
End Sub

Sub TaskBar_Show()
ShowWindow FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString), 5
End Sub

However,
This seems to be setting a visible flag for the task bar. What I need is

to
activate/deactivate the minimize of the task bar. (When you position the
mouse on the top line of the task bar, you get a double-headed arrow.

when
you click-drag down, it minimizes the task bar. This leaves a small line
which is the top of the task bar that you can grab and drag up to

un-minimize
the task bar).

How do I access that feature from VBA (using API or not)

I need this so that when I set my spreadsheet to show fullscreen, the

status
bar gets hidden under the taskbar (becuse I want to leave it set "always

on
top") I have found that manually minimizing then maximizing the taskbar
forces the status bar to show (I.E. the spreadsheet's full screen becomes
limited at the bottom to force both the taskbar and the (excel) statusbar

to
be both visible.)

Also Im curious what the & in the above "FindWindowEx&" API call code

does.
The code stops working when that character is removed.

--
Regards,
John



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
i want all windows in one excel frame (windows in taskbar) Subramanya Excel Discussion (Misc queries) 1 December 18th 09 03:14 PM
Windows Taskbar Jeff Setting up and Configuration of Excel 0 August 21st 08 05:08 PM
Windows in taskbar George Tattam Excel Discussion (Misc queries) 2 March 13th 06 10:31 AM
windows in taskbar jrlatt Setting up and Configuration of Excel 3 June 9th 05 02:09 PM
Controlling the windows taskbar from VBA? John Keith[_2_] Excel Programming 0 April 9th 05 04:57 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"