S
Simon Woods
Guest
Hi I have this C# code
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[Guid("20B4B529-5FE0-49ED-A225-AD376E48DA5A")]
public interface ITextBoxEvents
{
[DispId(1)] void GotFocus();
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(ITextBoxEvents))]
[Guid("59504737-9BEF-4AC9-ACEA-9E6192C4F446")]
public class TextBoxEvents
{
[ComVisible(false)] public delegate void GotFocusEvent();
public event GotFocusEvent GotFocus;
public void OnGotFocus(object s, RoutedEventArgs e) => RaiseGotFocusEvent();
public void RaiseGotFocusEvent() => GotFocus?.Invoke();
}
and this vb6 code
Private WithEvents m_oTextBoxEvents As IfxNetControls.TextBoxEvents
...
Private Sub UserControl_Initialize()
...
Set m_oTextBoxEvents = New IfxNetControls.TextBoxEvents
End Sub
...
Private Sub m_oTextBoxEvents_GotFocus()
Debug.Print "GotFocus"
End Sub
I can step the code in C# such that it tries to execute GotFocus. But the GotFocus delegate is null.
I had assumed that by adding the event handler in vb6 I was effectively subscribing to that GotFocus event. But obviously not. Do I need something concrete in the C# to fire the event to vb6.
Many thx
Continue reading...
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[Guid("20B4B529-5FE0-49ED-A225-AD376E48DA5A")]
public interface ITextBoxEvents
{
[DispId(1)] void GotFocus();
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(ITextBoxEvents))]
[Guid("59504737-9BEF-4AC9-ACEA-9E6192C4F446")]
public class TextBoxEvents
{
[ComVisible(false)] public delegate void GotFocusEvent();
public event GotFocusEvent GotFocus;
public void OnGotFocus(object s, RoutedEventArgs e) => RaiseGotFocusEvent();
public void RaiseGotFocusEvent() => GotFocus?.Invoke();
}
and this vb6 code
Private WithEvents m_oTextBoxEvents As IfxNetControls.TextBoxEvents
...
Private Sub UserControl_Initialize()
...
Set m_oTextBoxEvents = New IfxNetControls.TextBoxEvents
End Sub
...
Private Sub m_oTextBoxEvents_GotFocus()
Debug.Print "GotFocus"
End Sub
I can step the code in C# such that it tries to execute GotFocus. But the GotFocus delegate is null.
I had assumed that by adding the event handler in vb6 I was effectively subscribing to that GotFocus event. But obviously not. Do I need something concrete in the C# to fire the event to vb6.
Many thx
Continue reading...