|
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)
' 使用举例
' 最大化 Access 窗口
' fSetAccessWindow(SW_SHOWMAXIMIZED)
' 最小化 Access 窗口
' fSetAccessWindow(SW_SHOWMINIMIZED)
' 隐藏 Access 窗口
' fSetAccessWindow(SW_HIDE)
' 正常显示 Access 窗口
' 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 "除非屏幕上有一个窗口,否则不能隐藏 Access 主窗口!" _
& vbCr & vbCr _
& "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 "不能由屏幕上的 " & (loFORM.Caption + " ") & "窗体最小化 Access 主窗口!" _
& vbCr & vbCr _
& "Cannot minimize Access with " _
& (loFORM.Caption + " ") _
& "FORM on screen"
ElseIf nCmdShow = SW_HIDE And loFORM.PopUp <> True Then
MsgBox "不能由屏幕上的 " & (loFORM.Caption + " ") & "窗体隐藏 Access 主窗口!" _
& vbCr & vbCr _
& "Cannot hide Access with " _
& (loFORM.Caption + " ") _
& "FORM on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End Function
最上面的四行加在什么地方呢,麻烦老师讲解一下 |
|