Tutorials to .com

Tutorials to .com » Dotnet » Control-and-components » Prepared to use ActiveX Controls C # (a)

Prepared to use ActiveX Controls C # (a)

Print View , by: iSee ,Total views: 8 ,Word Count: 2789 ,Date: Fri, 22 May 2009 Time: 2:06 PM

Some time ago a Web project, we must have written an ActiveX control. Today, most of the ActiveX control is the use of vb / c + + to develop, and I am not familiar with them, so consider using the C++ # prepared with ActiveX controls.

First of all, the establishment of a winform control project HelloWorld, and drag a Label control text is set to HelloWorld, Figure:

UserControl1.cs reads as follows:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace HelloWorld
(
/**//// <summary>
/ / / UserControl1 summary.
/ / / </ Summary>
public class Demo: System.Windows.Forms.UserControl
(
private System.Windows.Forms.Label label1;
/**//// <summary>
/ / / Required designer variable.
/ / / </ Summary>
private System.ComponentModel.Container components = null;

public Demo ()
(
/ / The call is the Windows.Forms Form Designer necessary.
InitializeComponent ();

/ / TODO: Add in InitComponent any initialization after the call

)

/**//// <summary>
/ / / Clean up all the resources being used.
/ / / </ Summary>
protected override void Dispose (bool disposing)
(
if (disposing)
(
if (components! = null)
components.Dispose ();
)
base.Dispose (disposing);
)

Component Designer generated code # region Component Designer generated code
/**//// <summary>
/ / / Designer to support the required method - Do not use a code editor
/ / / Modify the contents of this method.
/ / / </ Summary>
private void InitializeComponent ()
(
this.label1 = new System.Windows.Forms.Label ();
this.SuspendLayout ();
/ /
/ / Label1
/ /
this.label1.Location = new System.Drawing.Point (32, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size (120, 32);
this.label1.TabIndex = 0;
this.label1.Text = "HelloWorld";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
/ /
/ / Demo
/ /
this.Controls.Add (this.label1);
this.Name = "Demo";
this.Size = new System.Drawing.Size (184, 96);
this.ResumeLayout (false);

)
# endregion
)
)

Compiler project at this time, can generate HelloWorld.dll. Copy this dll to the IIS virtual root directory, and then the establishment of a helloworld.htm documents, html code is as follows:
<body bgcolor='#223344'>
<object id="helloworld" classid='http://localhost/HelloWorld.dll#HelloWorld.Demo' Width="184" Height="96" VIEWASTEXT> </ object>
</ body>

.Net Control and components Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.