ActiveX.exe and RaiseEvent

  • Thread starter Thread starter Galen Somerville
  • Start date Start date
Hi Galen,

Thank you for your update.

Since we're trying to use Windows message to send back the data, I think
using a simple thread would be enough for our purpose.

We need to create a simple class to represent the parameters needs to pass
to the worker thread, I've created a simple method that needs three
parameters:

<vb6>

Public Sub DoWork(ByVal hwnd As Long, ByVal count As Long, ByVal delay As
Long)
Dim b(20) As Byte
Dim cds As COPYDATASTRUCT
Dim i As Long

For i = LBound(b) To UBound(b)
b(i) = i
Next

For i = 0 To count - 1
cds.cbData = 10
cds.lpData = VarPtr(b(0))
SendMessage ByVal hwnd, WM_COPYDATA, ByVal hwnd, cds
Sleep delay
Next
End Sub


<VB2005>

Public Class WorkerArgs
Public hwnd As IntPtr
Public count As Integer
Public delay As Integer

Public Sub New(ByVal h As IntPtr, ByVal c As Integer, ByVal d As
Integer)
hwnd = h
count = c
delay = d
End Sub
End Class

Then we use ParameterizedThreadStart to start this new thread:

<VB2005>

Dim worker As New vbworker.Class1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim t As Thread = New Thread(New ParameterizedThreadStart(AddressOf
DoWork))
t.Start(New WorkerArgs(Me.Handle, 10000, 1))
End Sub

Private Sub DoWork(ByVal arg As Object)
Dim wa As WorkerArgs = CType(arg, WorkerArgs)
worker.DoWork(wa.hwnd, wa.count, wa.delay)
End Sub

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Galen,

Since this thread is going rather long, to accelerate the process, you can
email me if you like. I'll be glad to continue working on this with you.
Thanks.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top