| |

VerySource

 Forgot password?
 Register
Search
View: 983|Reply: 8

Seek expert guidance for inter-program communication

[Copy link]

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-7 21:40:01
| Show all posts |Read mode
There are two programs A, B, and C in an ActiveX DLL file. The Report method is defined. A and B are referenced at the same time. A is the active side and B is the passive side. Began to process this message, now the problem is that B cannot trigger the Report method of C, please help me to give pointers, thank you!
C.
Public Function OnReport (rptStr As String) As String
End Function

A.
Set sendcls = New itfClass
sendcls.report “Hello”

B.
Private Function itfClass_OnReport (rptStr As String) As String
MsgBox rptStr
End Function
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 19:18:01
| Show all posts
Simply put:
When A changes, B must be notified to know that it is implemented by the DLL commonly referenced by both parties. Thank you!
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-19 09:54:01
| Show all posts
Seeing some people say that they must be implemented with activeX exe, is it necessary to do so? ?
Reply

Use magic Report

1

Threads

21

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 Great Britain

Post time: 2020-1-19 13:18:01
| Show all posts
Help you, let me learn
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-25 09:27:01
| Show all posts
'Use WM_COPYDATA to send messages

'Procedure 1
Private Const WM_COPYDATA =&H4A
Private Declare Function SendMessage Lib "user32" Alias ​​"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias ​​"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Type COPYDATASTRUCT
        dwData As Long
        cbData As Long
        lpData As Long
End Type

Private Sub Command1_Click ()
  Dim cd As COPYDATASTRUCT
  Dim temp As String
  Dim Data () As Byte
  Dim m As Long
  
    m = FindWindow ("ThunderRT6FormDC", "CopyData Test Form!")
  
    temp = "This is a Test Message!"
    Data = temp
    cd.cbData = UBound (Data) + 1
    cd.lpData = VarPtr (Data (0))
    cd.dwData = 0
  
    SendMessage m, WM_COPYDATA, 0, cd
End Sub








'Procedure 2
'Form
Private Declare Function SystemParametersInfo Lib "user32" Alias ​​"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const SPI_GETWORKAREA As Long = 48
    
Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Sub Form_Load ()
  Dim ret As Long
  prevWndProc = GetWindowLong (Me.hWnd, GWL_WNDPROC)
  ret = SetWindowLong (Me.hWnd, GWL_WNDPROC, AddressOf Windproc)
  Me.Caption = "CopyData Test Form!"
  Me.AutoRedraw = True
End Sub

Private Sub Form_Unload (Cancel As Integer)
  Dim ret As Long
  ret = SetWindowLong (Me.hWnd, GWL_WNDPROC, prevWndProc)
End Sub








'Module
Public Declare Function GetWindowLong Lib "user32" Alias ​​"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias ​​"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias ​​"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias ​​"RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

  Public Const WM_COPYDATA =&H4A
  Public Const GWL_WNDPROC = (-4)
Public prevWndProc As Long

Private Type COPYDATASTRUCT
        dwData As Long
        cbData As Long
        lpData As Long
End Type


Function Windproc (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   Dim Cd As COPYDATASTRUCT
   Dim Temp As String
   
   Select Case Msg
     Case WM_COPYDATA
       
       CopyMemory Cd, ByVal lParam, Len (Cd)
       Temp = Space (Cd.cbData)
       CopyMemory ByVal Temp, ByVal Cd.lpData, Cd.cbData
       Form1.Print StrConv (Temp, vbFromUnicode)

   End Select
    
    Windproc = CallWindowProc (prevWndProc, hWnd, Msg, wParam, lParam)
End Function
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-28 19:27:01
| Show all posts
dde can also be implemented and it is relatively simple, you google it
but. net does not support dde anymore
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-1 11:09:01
| Show all posts
Thank you for your answers. I have seen programs implemented using DLLs, but when I do it myself, I find that the event does not respond? ?
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-16 20:30:01
| Show all posts
Do not know how to achieve through DLL, please master to continue pointing.
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-21 15:30:01
| Show all posts
Come master
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list