patriciaxxx
Programmer
I have an Access 2003 db on win XP.
I’m trying to write code that will allow the Access application window to remain visible whilst hiding its taskbar button.
To clarify, if necessary, the Access application window visible is its natural state and I don’t want to change that. I just want to hide its taskbar button for that instance of Access. So if user opens another db whilst the hidden button one is open, the new db will be as normal ie taskbar icon visible & the hidden one will stay hidden.
I’ve posted the code I’m trying to adapt to achieve this below. I need the final code to be as robust as possible, it must work with Access 2003 / win XP and preferable on up through 2007 etc.
Any help would be very much appreciated.
I’m trying to write code that will allow the Access application window to remain visible whilst hiding its taskbar button.
To clarify, if necessary, the Access application window visible is its natural state and I don’t want to change that. I just want to hide its taskbar button for that instance of Access. So if user opens another db whilst the hidden button one is open, the new db will be as normal ie taskbar icon visible & the hidden one will stay hidden.
I’ve posted the code I’m trying to adapt to achieve this below. I need the final code to be as robust as possible, it must work with Access 2003 / win XP and preferable on up through 2007 etc.
Any help would be very much appreciated.
Code:
Option Compare Database
Option Explicit
Private Const WM_USER As Long = &H400
Private Const TB_HIDEBUTTON As Long = (WM_USER + 4)
Private Const TB_ISBUTTONHIDDEN As Long = (WM_USER + 12)
Private Const TB_DELETEBUTTON As Long = (WM_USER + 22)
Private Const TB_GETBUTTON As Long = (WM_USER + 23)
Private Const TB_BUTTONCOUNT = (WM_USER + 24)
Private Const TB_GETBUTTONTEXTA As Long = (WM_USER + 45)
Private Const TB_GETBUTTONTEXTW As Long = (WM_USER + 75)
Private Const TB_AUTOSIZE As Long = (WM_USER + 33)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private tWnd As Long
Private Sub Command1_Click()
Dim bWnd As Long
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
bWnd = FindWindowEx(tWnd, bWnd, "BUTTON", vbNullString) 'Start button handle
tWnd = FindWindowEx(tWnd, 0, "ReBarWindow32", vbNullString)
tWnd = FindWindowEx(tWnd, 0, "MsTaskSwWClass", vbNullString)
tWnd = FindWindowEx(tWnd, 0, "ToolbarWindow32", vbNullString) 'Taskbar handle
SendMessage tWnd, TB_BUTTONCOUNT, 0, 0
SendMessage tWnd, TB_HIDEBUTTON, 1, 0
End Sub