Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show Access app window but hide its taskbar button

Status
Not open for further replies.

patriciaxxx

Programmer
Jan 30, 2012
277
GB
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.

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

 
Patricia,

Leave the post open, but this isn't really specific to MS Access - would it be better described as 'Windows programming'?

I do understand that in this case, it's for MS Access specifically, but, you are attempting to control Windows OS functionality no?

You may find that you get more / better responses under other 'higher level' topics.

As a note, I personally can't imagine how this could be useful (at all). You are after all attempting to take (good Windows) control away from Windows.
Why only have the latest instance with a taskbar 'button'?
If it is the 'latest' instance - it must be visible, overlaying the previous instances - why would you need a taskbar 'button' to 'select' it?

Now, I could (sort of) understand hiding the LATEST / currently visible instance taskbar icon (why show it if the instance is already visible?).
But, hiding them all, so the taskbar shortcut only allows you to select the most active instance / the instance that is already visible - makes no sense.

I'm sure that you'll surprise my unadventurous little brain with a brilliant response however.

D ;-)





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top