Hi, I am trying to make an ActiveX-like control in C# per the following
article:
http://www.c-sharpcorner.com/Code/20...tiveXInNet.asp
The control I make compiles, but when I added it to my HTML Application
(.HTA) file, it won't display. I found another article that said this
would run only as HTML from a webserver. I tried this and it works. I
want to run this from a .HTA file, with no web server involved. Is it
possible? Do I perhaps have something wrong with the code?
Here is what the .HTA file looks like:
---------------------------------------------
<html>
<body>
<OBJECT id="OutLogCtl1"
classid="AXOutLog.dll#AXOutLog.OutLogCtl" width="352" height="80">
</OBJECT>
</body>
</html>
---------------------------------------------
And the C# library code:
---------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace AXOutLog
{
public interface AXOutLogCtl
{
string addString { set; get; }
}
/// <summary>
/// Summary description for OutLogCtl.
/// </summary>
public class OutLogCtl : System.Windows.Forms.UserControl, AXOutLogCtl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.TextBox textBox1;
private string lastAdd;
public string addString
{
get { return lastAdd; }
set
{
textBox1.Text = textBox1.Text + value;
lastAdd = value;
}
}
public OutLogCtl()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 8);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(336, 64);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// OutLogCtl
//
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBox1});
this.Name = "OutLogCtl";
this.Size = new System.Drawing.Size(352, 80);
this.ResumeLayout(false);
}
#endregion
}
}
---------------------------------------------
Thanks,
JA