471,350 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

C# ActiveX-like User Control in .HTA file

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
Dec 9 '05 #1
1 3544
gilad wrote:
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?


Not to answer my own question, but this works if you do a "regasm
/codebase <dllname>", then look up the CLSID in the registry and access
it in the "standard" ActiveX way, i.e. with a GUID. My .HTA file looks like

<html>
<body>

<OBJECT id="OutLogCtl1"
classid="CLSID:B1943A0E-C4EB-3308-A9EE-3AF1789B5572" width="352"
height="80">
</OBJECT>
</body>

</html>

and the control loads. Is this the only way to make this work on .HTA files?

Thanks,

JA
Dec 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by AnalogKid | last post: by
2 posts views Thread by Kuba Florczyk | last post: by
3 posts views Thread by | last post: by
3 posts views Thread by shypen42 | last post: by
6 posts views Thread by libsfan01 | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.