Hiding the access background window (1 Viewer)

k0r54

Registered User.
Local time
Today, 06:36
Joined
Sep 26, 2005
Messages
94
Hi,

Ok i am using the following code to hide the access window but when i do it, it also hides it from the taskbar aswell.

Is there any modifications to the code that will hide the background window but also keep it on the taskbar.

thanks
k0r54

Module: -
Code:
Option Compare Database

Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Dim dwReturn As Long

Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, _
     ByVal nCmdShow As Long) As Long

Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean

  If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
  End If
  If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
  End If
  If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
  End If
  If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
  End If
  
  If StatusCheck = True Then
    If IsWindowVisible(hWndAccessApp) = 0 Then
        fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then
        fAccessWindow = True
    End If
  End If
End Function

To call it: -
Code:
  HideForm = fAccessWindow("Hide", False, False)
 

Smart

Registered User.
Local time
Today, 06:36
Joined
Jun 6, 2005
Messages
436
Use tools start up and de select display database window
 

k0r54

Registered User.
Local time
Today, 06:36
Joined
Sep 26, 2005
Messages
94
Hi,

Im affraid that doesn't do it :(
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
If anyone could answer this question (first post above), that is the answer I am looking for. I have looked all over for the code the hide the access window, but still display the taskbar so the user can see they have the application open if other applications are open as well.

Ok i am using the following code to hide the access window but when i do it, it also hides it from the taskbar as well.

Is there any modifications to the code that will hide the background window but also keep it on the taskbar.

Thanks in advance.

Kevin
 

ions

Access User
Local time
Yesterday, 22:36
Joined
May 23, 2004
Messages
791
To hide the database window:

Private Sub cmdHide_Click()
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
End Sub

To show the database window:

Private Sub cmdShow_Click()
DoCmd.SelectObject acTable, , True
DoCmd.SelectObject acForm, Me.Name
End Sub
 

boblarson

Smeghead
Local time
Yesterday, 22:36
Joined
Jan 12, 2001
Messages
32,059
To hide the database window:

Private Sub cmdHide_Click()
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
End Sub

To show the database window:

Private Sub cmdShow_Click()
DoCmd.SelectObject acTable, , True
DoCmd.SelectObject acForm, Me.Name
End Sub

ions: Hiding the database window is not what they were talking about. It was hiding the Application window (the whole container that Access has open when you open a database, not just the database window where the objects (Tables, Queries, Forms, Macros, Reports, and Modules) are listed.
 

missinglinq

AWF VIP
Local time
Today, 01:36
Joined
Jun 20, 2003
Messages
6,420
Is this what you want? This code

Code:
Private Sub Form_Load()
    DoCmd.RunCommand acCmdAppMinimize
End Sub

Hides the Access app window and places the db in the taskbar, so that if you have a form set in Startup to open when the db is started, the form appears "free floating" if you will, on the desktop. Depending on the size of the form, you may also have to deselect Display Database Window in Startup to keep it from showing.
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
Not quite what I wanted...

Thank you for the reply. That works like you described, but with the popup menus that I am using on my switchboard that method won't work.

Here is an example of what my switchboard looks like...



I am currently using the API method that you can find on Dev Ashish's website. It (1) minimizes the Access window which I want and it (2) lets me use the popups on my switchboard which I want, but it won't (3) let me see the window in the taskbar.

Your method...

Code:
Private Sub Form_Load()
    DoCmd.RunCommand acCmdAppMinimize
End Sub

...works, but only does (1) and (3) above. Not (2), which is vital to my program. I don't even know if what I want is possible. Thanks for your help in advance.

Kevin
 

ssteinke

for what it's worth
Local time
Today, 01:36
Joined
Aug 2, 2003
Messages
195
Is your Switchboard set to Popup & Modal... if this is the case, I don't believe it is possible to use 'Popup menus' under those conditions. I don't even think the default 'Right click' menus work on forms set to popup, which I suspect is common Windows trait. Let me know if I'm on the right track.
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
Yes, my switchboard is set to Popup and Modal. If you set Popup to 'No' then you won't see it on load if you are hiding the access window using the
Code:
DoCmd.RunCommand acCmdAppMinimize
method. I can get the Popup toolbars to work if I use the API method of hiding the window, but I can't see it in the taskbar.

You are also correct about the right click not working, but only when you are using the
Code:
DoCmd.RunCommand acCmdAppMinimize
method. Right click will work if you use the API method, but again I can't see it in the taskbar.
 

ssteinke

for what it's worth
Local time
Today, 01:36
Joined
Aug 2, 2003
Messages
195
kgraue,

FYI, I seem to recall trying to work through this very same issue a couple of years ago and was never able to come up with a satisfactory solution. I ultimately stopped hiding the Access window because of it.

Let me know if you find another solution,

Scott
 

DJkarl

Registered User.
Local time
Today, 00:36
Joined
Mar 16, 2007
Messages
1,028
Yes, my switchboard is set to Popup and Modal. If you set Popup to 'No' then you won't see it on load if you are hiding the access window using the
Code:
DoCmd.RunCommand acCmdAppMinimize
method. I can get the Popup toolbars to work if I use the API method of hiding the window, but I can't see it in the taskbar.

You are also correct about the right click not working, but only when you are using the
Code:
DoCmd.RunCommand acCmdAppMinimize
method. Right click will work if you use the API method, but again I can't see it in the taskbar.

Rather than hiding the application window try using the Movewindow API

Code:
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

This will allow you to minimize the window and move it off the viewable desktop, but it will still show up in the taskbar.
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
DJkarl,

What do I pass to MoveWindow for hwnd? I remember seeing somewhere what I should use here if I want to move the main access window, but I can't remember what it was. Do you know? Thanks.

Kevin
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
Nevermind I figured it out. It was hWndAccessApp. Sorry.

Kevin
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
Got it...somewhat

Ok, so for everyone watching this post to see if there finally was a solution i think DJkarl got the closest.

It seems like any method you use to try and hide the access window you are always going to have a part of your database that "isn't that likable." I say that because if you use DJkarl's method of "hiding" the access window then you are forced to set the coordinates of the window so large that they window itself is visible but you can't see it because it isn't on your screen. Kind of loop hole so to speak. The "not so likable" thing here is that you can't use autocenter which is upsetting. If you do, then each time you open a form it will move to the corner of your screen (however you set the coordinates) because it wants to try and get in the center of the "hidden" access window.

Unless I am missing something DJkarl I think you just have to pick which method suits your database the best and try and make the best of it. It sounds like some people just went away with trying to hide the access window because of this.

It's a shame though because in my opinion I think that when you hide the access window it looks so much better, just like an actual stand alone program would to some degree.

Anyway, thank you for everyone that helped with this thread and if you have any more suggestions or ways to fix any of the problems with any method of hiding the window please post it here so I will know about it.

Thanks again!

Kevin
 

DJkarl

Registered User.
Local time
Today, 00:36
Joined
Mar 16, 2007
Messages
1,028
Here's the function I use to set the minimize and move the window in one of my applications.

I call the function in the form load event with the following arguments
AdjstAccssWndw(-1000, -1000), the database window doesn't show up at all on my screen. You may also want to put something in the form close event to resize the database window to normal like AdjstAccssWndw(1000, 650), I do this in my developement copy so I don't have to continually close and re-open the DB.

Code:
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long


Public Const SM_CXSCREEN = 0 'X Size of screen
Public Const SM_CYSCREEN = 1 'Y Size of Screen


Public Function AdjstAccssWndw(Optional ByVal MyX As Long = 200, Optional ByVal MyY As Long = 25)
    Dim errNum As Long, errDesc As String
    On Error GoTo SubEx
    Call MoveWindow(Application.hWndAccessApp, CLng(Round((GetSystemMetrics(SM_CXSCREEN) - MyX) / 2, 0)), CLng(Round((GetSystemMetrics(SM_CYSCREEN) - MyY) / 2, 0)), MyX, MyY, True)
ExitMe:
    Exit Function
SubEx:
    errNum = Err.Number: errDesc = Err.Description: Err.Clear
    Debug.Print errNum & errDesc
    Resume ExitMe
End Function
 

kgraue

Registered User.
Local time
Today, 00:36
Joined
Aug 16, 2006
Messages
12
Thanks DJkarl for the help. This works great and it is just what I was looking for.

Kevin
 

Users who are viewing this thread

Top Bottom