Udostępnienie zdarzeń kontrolki .NET w AmBasic
Witam
Mam problem z udostępnieniem zdarzenia kontrolki .NET w AmBasicu. Poniżej kod kontrolki C#:
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
using Microsoft.Win32;
using System.Threading;
namespace ActiveXSourcing
{
[ComVisible(true)]
public delegate void ClickEventHandler(int x, int y);
[GuidAttribute("0422D916-C11A-474e-947D-45A107038D12")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
[ComVisible(true)]
public interface ControlEvents
{
[ComVisible(true)]
[DispIdAttribute(0x60020000)]
void ClickEvent(int x, int y);
}
[ProgId("ActiveXSourcing.MyWindowControl")]
[ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof(ControlEvents))]
[Guid("7C21F7A3-6CFE-4E7B-AA2C-AEC09D4C39D5")]
[ComVisible(true)]
public class MyWindowControl : System.Windows.Forms.UserControl
{
System.Windows.Forms.TextBox tx = new TextBox();
private void InitializeComponent()
{
this.Name = "MyWindowControl";
}
event ActiveXSourcing.ClickEventHandler ClickEvent;
public MyWindowControl()
: base()
{
initMyWindowControl();
}
private void initMyWindowControl()
{
Size = new System.Drawing.Size(300, 50);
tx.Text = "Click on the TextBox to invoke 'ClickEvent'";
tx.Size = this.Size;
tx.Click += new System.EventHandler(ClickHandler);
this.Controls.Add(tx);
}
[ComVisible(true)]
private void ClickHandler(object sender, System.EventArgs e)
{
if (ClickEvent != null)
{
ClickEvent(0, 0);
}
}
}
}
A tak to wygląda w AmBasicu:
Kod:
dispatch ct1
int id1
int Sub ct1_ClickEvent(int a,int b)
message "Klik"
endsub
Int Sub OnCommand(int id, int msg)
If id == id1 Then
endif
EndSub
form "Test",600,300
control "ActiveXSourcing.MyWindowControl", ct1,10,10,500,200
id1 = button "ok",25,250,50,20,1
int ext = execform OnCommand
error ""
Kontrolka jest widoczna w formie ale nie reaguje na kliknięcie. Co może być przyczyną?