假设ACTIVX 的类名为 AXTTest,
1. 创建一个FORM (frmTest)
public class frmTest : System.Windows.Forms.Form
{
private AXTest m_axTest;
public AXTest AxTest { get { return m_axTest;}}
public frmTAPI()
{
InitializeComponent();
this.CreateControl();
}
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmTest));
this.m_axTest = new AXTest();
((System.ComponentModel.ISupportInitialize)(this.m_axTest)).BeginInit();
this.SuspendLayout();
//init m_axTest
this.m_axTest.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("m_axTest.OcxState")));
.....
this.Controls.Add(this.m_axTest);
((System.ComponentModel.ISupportInitialize)(this.m_axTest)).EndInit();
this.ResumeLayout(false);
}
}
2.在外部程序创建frmTest 实例(m_frmTest)
3. 使用Activex , m_frmTest.AXTest
1. 创建一个FORM (frmTest)
public class frmTest : System.Windows.Forms.Form
{
private AXTest m_axTest;
public AXTest AxTest { get { return m_axTest;}}
public frmTAPI()
{
InitializeComponent();
this.CreateControl();
}
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmTest));
this.m_axTest = new AXTest();
((System.ComponentModel.ISupportInitialize)(this.m_axTest)).BeginInit();
this.SuspendLayout();
//init m_axTest
this.m_axTest.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("m_axTest.OcxState")));
.....
this.Controls.Add(this.m_axTest);
((System.ComponentModel.ISupportInitialize)(this.m_axTest)).EndInit();
this.ResumeLayout(false);
}
}
2.在外部程序创建frmTest 实例(m_frmTest)
3. 使用Activex , m_frmTest.AXTest