2011/01/05

office2010 Win32API 条件付きコンパイル WindowFromPoint

#If VBA7 Then
'************** VBA7共通 **************
Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long

Declare PtrSafe Sub CopyMemory Lib "kernel32" _
                                Alias "RtlMoveMemory" ( _
                                Destination As Any, _
                                Source As Any, _
                                ByVal Length As LongPtr)
'**************************************
    #If Win64 Then
    '************** VBA7x64用 **************
    Declare PtrSafe Function GetWindowLong Lib "user32" _
                                    Alias "GetWindowLongPtrA" ( _
                                    ByVal hwnd As LongPtr, _
                                    ByVal nIndex As Long _
                                    ) As LongPtr
     
    Declare PtrSafe Function SetWindowLong Lib "user32" _
                                    Alias "SetWindowLongPtrA" ( _
                                    ByVal hwnd As LongPtr, _
                                    ByVal nIndex As Long, _
                                    ByVal dwNewLong As LongPtr _
                                    ) As LongPtr
    
    Declare PtrSafe Function GetTickCount64 Lib "kernel32" () As LongLong
      
    Declare PtrSafe Function WindowFromPoint Lib "user32" ( _
                                    ByVal point As LongLong _
                                    ) As LongPtr
     
    Type POINTAPI
            x As Long
            y As Long
    End Type
     
    Function PointToLongLong(point As POINTAPI) As LongLong
        Dim ll As LongLong
        Dim cbLongLong As LongPtr
         
        cbLongLong = LenB(ll)

        If LenB(point) = cbLongLong Then
            CopyMemory ll, point, cbLongLong
        End If
         
        PointToLongLong = ll
    End Function
    '***************************************
    #Else
    '************** VBA7x86用 **************
    Declare PtrSafe Function GetWindowLong Lib "user32" _
                                    Alias "GetWindowLongA" ( _
                                    ByVal hwnd As LongPtr, _
                                    ByVal nIndex As Long _
                                    ) As LongPtr
     
    Declare PtrSafe Function SetWindowLong Lib "user32" _
                                    Alias "SetWindowLongA" ( _
                                    ByVal hwnd As LongPtr, _
                                    ByVal nIndex As Long, _
                                    ByVal dwNewLong As LongPtr _
                                    ) As LongPtr
     
    Declare PtrSafe Function WindowFromPoint Lib "user32" ( _
                                    ByVal xPoint As Long, _
                                    ByVal yPoint As Long _
                                    ) As LongPtr
    '***************************************
    #End If
#Else
'************** Office2007以前 **************
Declare Function GetWindowLong Lib "user32" _
                                Alias "GetWindowLongA" ( _
                                ByVal hwnd As Long, _
                                ByVal nIndex As Long _
                                ) As Long
 
Declare Function SetWindowLong Lib "user32" _
                                Alias "SetWindowLongA" ( _
                                ByVal hwnd As Long, _
                                ByVal nIndex As Long, _
                                ByVal dwNewLong As Long _
                                ) As Long
 
Declare Function GetTickCount Lib "kernel32" () As Long
 
Declare Function WindowFromPoint Lib "user32" ( _
                                ByVal xPoint As Long, _
                                ByVal yPoint As Long _
                                ) As Long
#End If

0 件のコメント: