0

用于隐藏实际访问窗口的 fAccessWindow ("Hide", False, False) 函数给出编译错误号 7960

我试过没有空格“fAccessWindow(“隐藏”,假,假)“但没有区别。我在一个模块中也有下面的代码,也可以在这里找到。我正在使用具有最低级别的宏安全性的 Access 2010。我的操作系统也是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 IsWindowVisible(hWndAccessApp) = 1 Then
        fAccessWindow = True
    End If
End If
End Function
4

2 回答 2

2

您需要参考MS 的这篇关于 64 位 VBA 的文章,不仅要使用 PtrSafe,还要使用新的 LongLong 数据类型,并且您需要使用条件编译:

  #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

我不是为 64 位 Access 编程,所以没有使用过这个。我不清楚 Win64 和 VBA7 编译常量之间的交互是什么,引用的文章也不是很清楚。我不清楚你是否应该这样做:

  #If Win64 And VBA7 Then
      ...
  #Else
      ...
  #End If

或者如果应该是:

  #If Win64 Then
      #If VBA7 Then
         ...
      #Else
         ...
      #End If
  #Else
      #If VBA7 Then
         ...
      #Else
         ...
      #End If
  #End If
于 2011-03-10T01:20:11.757 回答
0

我在下面的函数中添加了 PtrSafe 选项,它开始在 x64 中工作,但现在它在 x86 机器上给出了同样的错误。

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
于 2011-03-09T22:58:01.490 回答