> I would appreciate help with the events very much.
There is no reason for events not to work with this proxy setup per se. Here is my test VB6 code
Code:
'--- Form1
Option Explicit
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private m_oProxy64 As Object
Private WithEvents m_Voice As SpeechLib.SpVoice
Private WithEvents m_oFont As StdFont
Private Sub Command1_Click()
On Error GoTo EH
If m_oProxy64 Is Nothing Then
Set m_oProxy64 = GetObject("MyApp.MyProxy")
End If
If m_oFont Is Nothing Then
Set m_oFont = m_oProxy64.CreateObject("StdFont")
End If
m_oFont.Size = m_oFont.Size + 2
Print "m_oFont.Size " & m_oFont.Size, GetCurrentThreadId
Exit Sub
EH:
MsgBox Err.Description, vbCritical
Set m_oFont = Nothing
Set m_oProxy64 = Nothing
End Sub
Private Sub m_oFont_FontChanged(ByVal PropertyName As String)
Print "m_oFont_FontChanged " & PropertyName, GetCurrentThreadId
End Sub
This works for
StdFont instances and
FontChanged event is received from x64 instance.
You don't have to use
New to receive events i.e.
CreateObject works fine as long as your variables is declared
WithEvents ... As Strong.Type for early-bound access.
FYI, this is early-bound:
Dim oFont As StdFont
Set oFont = CreateObject("StdFont")
This is late-bound:
Dim oFont As Object
Set oFont = New StdFont
This is early-bound too:
Dim oFont As StdFont
Set oFont = New StdFont
. . . so it does not matter if instance is created with
New or
CreateObject, it only matter how the variable is dimensioned i.e.
As Strong.Type vs
As Object. This is has always been the case, it is not something in connection with x64 vs x86 instancing we are discussing here.
Anyway, obviously there is some incompatibility with
SAPI.SpVoice in the way events are fired. Probably connected with threading/async implementation which boggles cross-process bridge OS is providing.
Just tested x86 build of the proxy project -- events don't fire cross-process too.
About
Private WithEvents m_Voices() As SpVoice syntax -- obviously arrays are not supported in VB6 like this so this is a nice extension to the language in TB which is not completely implemented i.e. events are not massaged to have index property. Apparently ETA on this feature getting fixed can only be shared by Wayne.
One way going forward from here is to implement event stubs in TB and forward these as function calls to a callback object in VB6, something like this
Code:
Private WithEvents m_oVoice As SpeechLib.SpVoice
Private m_oCallback As Object
Public Function CreateSpVoice(oCallback As Object) As Object
Set m_oVoice = New SpeechLib.SpVoice
Set m_oCallback = oCallback
Set CreateSpVoice = m_oVoice '--- fixed: setting retval was missing
End Function
Private Sub m_oVoice_StartStream(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
If Not m_oCallback Is Nothing Then
m_oCallback.SpVoice_StartStream StreamNumber, StreamPosition
End If
End Sub
Private Sub m_oVoice_Word(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal CharacterPosition As Long, ByVal Length As Long)
If Not m_oCallback Is Nothing Then
m_oCallback.SpVoice_Word StreamNumber, StreamPosition, CharacterPosition, Length
End If
End Sub
cheers,
</wqw>