Option Explicit
Private Type RECT
 Left As Long
 Top As Long
 Right As Long
 Bottom As Long
End Type
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long编译错误: 在私有对象模块中不能定义Public的用户类型. 
将type 前加 private,则错成 Private Enum以及用户定义类型不能作为参数。
将type 改加 public, 则错成 在私有对象模块中不能定义public的用户定义类型。
请问,如何修改程序?

解决方案 »

  1.   


     Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long前加上Private的话,就没有错误了~
      

  2.   

    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long或是
    把API声明写到一个模块文件中(.BAS)Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
      

  3.   

    还有一种方法就是做成.Dll的类模块中声明,有过这样的铁子,自己找找
      

  4.   

    Private Type RECT 的定义不能放到frm中 应该放到bas里面