A
Afrosheen via AccessMonster.com
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that maximizes
the screen. It is from a Login form that puts the form on the desktop. These
are the two routines that I'm using. The problem is that when Access Hides
and then reopens [Maximizes] it maximizes so big that none of the menus are
showing. Not even my custom menu which I need. Maybe there's something in the
code that shuts out everything else. I don't know
Private Sub Form_Open(Cancel As Integer)
10 On Error GoTo ErrorPoint
DoCmd.RunCommand acCmdSizeToFitForm 'Sets up the Login Screen
Me.Visible = True
DoEvents
fSetAccessWindow (SW_HIDE)
ExitPoint:
40 Exit Sub
ErrorPoint:
50 MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
60 Resume ExitPoint
End Sub
Private Sub Form_Close()
fSetAccessWindow (SW_SHOWMAXIMIZED)
40 Me.Visible = False
50 Application.CommandBars("myMenu").Enabled = True
70 DoCmd.OpenForm "frmLinkToDatabases"
End Sub
This is the API:
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'************ Code Start **********
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox "Cannot hide Access unless " _
& "a form is on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
Else
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End Function
'************ Code End **********
I'm trying to get my custom menu bar working after an API call that maximizes
the screen. It is from a Login form that puts the form on the desktop. These
are the two routines that I'm using. The problem is that when Access Hides
and then reopens [Maximizes] it maximizes so big that none of the menus are
showing. Not even my custom menu which I need. Maybe there's something in the
code that shuts out everything else. I don't know
Private Sub Form_Open(Cancel As Integer)
10 On Error GoTo ErrorPoint
DoCmd.RunCommand acCmdSizeToFitForm 'Sets up the Login Screen
Me.Visible = True
DoEvents
fSetAccessWindow (SW_HIDE)
ExitPoint:
40 Exit Sub
ErrorPoint:
50 MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
60 Resume ExitPoint
End Sub
Private Sub Form_Close()
fSetAccessWindow (SW_SHOWMAXIMIZED)
40 Me.Visible = False
50 Application.CommandBars("myMenu").Enabled = True
70 DoCmd.OpenForm "frmLinkToDatabases"
End Sub
This is the API:
'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'************ Code Start **********
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox "Cannot hide Access unless " _
& "a form is on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
Else
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End Function
'************ Code End **********