[AccessD] ISFEMessaging Class (talking between applications)

Drew Wutka DWUTKA at Marlow.com
Mon Jul 16 16:55:54 CDT 2007


Option Explicit
Private Declare Function CreateWindowEx Lib "user32" Alias
"CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String,
ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long,
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long,
lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long)
As Long
Private Declare Function SetWindowLong Lib "user32" Alias
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal
dwNewLong As Long) As Long
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long
Const GWL_WNDPROC = -4
Public PreviousHwnd As Long
Public ISFE2007hWnd As Long
Dim intMessageHookHwnd As Long
Dim intISFEMessageID As Long
Event ISFEMessage(im As ISFEMessage)
Event HandshakeCompleted(intRemoteHwnd As Long)
Private Sub Class_Initialize()
intISFEMessageID = RegisterWindowMessage("ISFEMessage")
intMessageHookHwnd = CreateWindowEx(0, "STATIC", "", 0, 0, 0, 0, 0, 0,
0, App.hInstance, ByVal 0&)
PreviousHwnd = SetWindowLong(intMessageHookHwnd, GWL_WNDPROC, AddressOf
WindowProc)
End Sub
Public Function IncomingWindowMessage(intMessage As Long, intWParameter
As Long, intLParameter As Long)
Select Case intMessage
    Case intISFEMessageID
        Dim im As ISFEMessage
        Set im = New ISFEMessage
        im.FirstParameter = intWParameter
        im.SecondParameter = intLParameter
        im.ProcessIncomingData
        If Not ProcessMessage(im) Then RaiseEvent ISFEMessage(im)
        Set im = Nothing
End Select
End Function
Private Sub Class_Terminate()
Dim dwReturn As Long
dwReturn = SetWindowLong(intMessageHookHwnd, GWL_WNDPROC, PreviousHwnd)
DestroyWindow intMessageHookHwnd
End Sub
Public Function SendISFEMessage(ByVal inthWnd As Long, ByVal
intParameter1 As Long, ByVal intParameter2 As Long)
SendMessage inthWnd, intISFEMessageID, intParameter1, intParameter2
End Function
Public Function Handshake()
Dim im As ISFEMessage
Set im = New ISFEMessage
im.MessageType = "Handshake"
im.SecondParameter = intMessageHookHwnd
im.BroadcastData
Set im = Nothing
End Function
Private Function ProcessMessage(im As ISFEMessage) As Boolean
ProcessMessage = True
Select Case im.MessageType
    Case "Handshake"
        If im.SecondParameter <> intMessageHookHwnd Then
            If Me.ISFE2007hWnd = 0 Then
                Me.ISFE2007hWnd = im.SecondParameter
                im.SecondParameter = intMessageHookHwnd
                im.SendData
                RaiseEvent HandshakeCompleted(Me.ISFE2007hWnd)
            End If
        End If
    Case Else
        ProcessMessage = False
End Select
End Function

The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI BusinessSensitve material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.





More information about the AccessD mailing list