Office中国论坛/Access中国论坛

标题: 判断窗体状态的函数(Windowstate) [打印本页]

作者: tmtony    时间: 2008-4-25 22:01
标题: 判断窗体状态的函数(Windowstate)
Access的Application没有 Windowstate 这一属性
写了一个, 可以 GetWindowState(me)来获取当前窗体的状态

Option Compare Database
Declare Function apiGetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
Declare Function apiGetParent Lib "user32" Alias "GetParent" (ByVal hwnd As Long) As Long
                    

Declare Function apiIsIconic Lib "user32" Alias "IsIconic" (ByVal hwnd As Long) As Long
Declare Function apiIsZoomed Lib "user32" Alias "IsZoomed" (ByVal hwnd As Long) As Long
                    

Private Function IsAccessMaximized(rfrm As Form)
    If apiIsZoomed(rfrm.hwnd) = 0 Then   'GetAccesshWnd()
        IsAccessMaximized = False
    Else
        IsAccessMaximized = True
    End If
End Function
Private Function IsAccessMinimized(rfrm As Form)
    If apiIsIconic(rfrm.hwnd) = 0 Then
        IsAccessMinimized = False
    Else
        IsAccessMinimized = True
    End If
End Function
Private Function IsAccessRestored(rfrm As Form)
    If IsAccessMaximized(rfrm) = False And _
         IsAccessMinimized(rfrm) = False Then
        IsAccessRestored = True
    Else
        IsAccessRestored = False
    End If
End Function

Public Function GetWindowState(rfrm As Form) As Integer
If IsAccessMaximized(rfrm) = True Then
     GetWindowState = 2
     Exit Function
     
End If
If IsAccessMinimized(rfrm) = True Then
     GetWindowState = 0
     Exit Function
Else
    GetWindowState = 1
     Exit Function
End If
  
End Function
作者: chenwm1973    时间: 2008-4-25 22:23
[:50] [:50] [:50]
作者: Grant    时间: 2008-4-26 00:41
谢谢收藏了
作者: andymark    时间: 2008-4-26 01:03
谢谢分享!!
作者: t小宝    时间: 2008-4-26 14:14
收藏了,谢谢[:50]
作者: chaojianan    时间: 2009-9-27 11:04
谢谢,收藏了。




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3