fAccessWindow ("Hide", False, False) function for hiding actual access window gives compilation error number 7960
I have tried without space "fAccessWindow("Hide", False, False)" but no difference. I also have code below in a module which can be also found here. I'm using Access 2010 with lowest level of macro security. Also my operating system is x64.
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 IsWi开发者_Python百科ndowVisible(hWndAccessApp) = 1 Then
fAccessWindow = True
End If
End If
End Function
You need to refer to this article from MS on 64-bit VBA and use not just PtrSafe, but also the new LongLong data type, and you'll need to use conditional compilation:
#if Win64 then
Private Declare PtrSafe Function IsWindowVisible Lib "user32" (ByVal hwnd As LongLong) As LongLong
#else
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
#end if
I am not programming for 64-bit Access so have not worked with this. It is unclear to me what the interaction between the Win64 and VBA7 compilation constants are, and the cited article isn't exactly clear on it. It's not clear to me if you should do this:
#If Win64 And VBA7 Then
...
#Else
...
#End If
or if it should be:
#If Win64 Then
#If VBA7 Then
...
#Else
...
#End If
#Else
#If VBA7 Then
...
#Else
...
#End If
#End If
I've added PtrSafe option to functions below and it started to work in x64 but now it is giving same error on x86 machines.
Private Declare PtrSafe Function IsWindowVisible Lib "user32"_
(ByVal hwnd As Long) As Long
Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
精彩评论