473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 3707
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: AnalogKid | last post by:
Short question: What's the difference between SingleUse and MultiUse ? Long question: I've been writing some sample code to see how different Instancing values and threading models work. I...
2
by: Kuba Florczyk | last post by:
Hi Do anybody know how to show ActiveX whitout AxHost? For example i got wrapper to ActiveX and now i don't know how AxHost shows ActiveX. I must do it, because i think AxHost made it wrong...
7
by: NewbieJon | last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script) ...
3
by: Matik | last post by:
Hello everyone, I was wondering. Is it possible, to recive an event from ActiveX into database? I was looking alredy with notification services, but I think that's the wrong way. Lets say,...
3
by: | last post by:
Hello All, I am doing some research on ActiveX and it's place in .NET. In .NET, does ActiveX have an equivalent counterpart. Where would I be able to locate information on this subject. Thanks.
0
by: Sorin | last post by:
Hi all I have a .NET application that is using few ActiveX DLL wrote in VB6. I managed to get the most from my previous VB6 controls by using them in .NET but sometimes when I am using my...
3
by: DB | last post by:
Hi Folks, I want to create Activex component. Can we create it using c#.net or do I need to create it using vc++? Thanks in Advanced, Deepak
2
by: cn99 | last post by:
Hello, I have develop an ActiveX with Visual C++ 6 And I will call functions on this ActiveX from a javascript. I know how to instantiate the activex object (with the balise <object>). ...
3
by: shypen42 | last post by:
Hi everybody, I'm pretty new to Javascript (I'm more on the server-side usually :) I've been doing some XMLHttp request lately, communicating in an "Ajax" style (to be buzzword compliant) with...
6
by: libsfan01 | last post by:
Hi all Im trying to use prototype for an xmlhttprequest, but it doesn't seem to be working cross-browser. Is there someway of getting it to be IE6 compatible (active x)? here's my code so...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.