Hi,
I have a problem with reading the param that is in the html code:
this is just a test. i've impelmented the ipersistpropertybag interface but my load method never seams to be called.
the code looks like this:
Code:
notice that in the button event i try to get even an info that the load was called but the aa value never changes from "not called
I have a problem with reading the param that is in the html code:
Code:
<html>
<head>
<script LANGUAGE="JavaScript1.2">
function Scrape( )
{
var objDownload = new ActiveXObject( "TiborActiveX1.Download1" );
try
{
objDownload.InvokeMethod( );
}
catch(exception) {
alert( "Failed" );
}
}
</script>
</head>
<body>
<table align="center">
<td>
<a href="javascript:Scrape( )">Invoke Component</a>
</td>
</table>
<p>Please Wait...Downloading components...</p>
<object name="secondobj" id='TestActivex' classid='CLSID:A47C22B1-3CC3-45bc-801E-3FCC4FFD3E45' codebase='DownloadDeployer.cab#version=1,0,0,0'>
<PARAM NAME="Server" VALUE="TestServer">
</object>
</body>
</html>
this is just a test. i've impelmented the ipersistpropertybag interface but my load method never seams to be called.
the code looks like this:
Code:
Code:
using System;
using System.Text;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Diagnostics;
namespace TiborActiveX1
{
[ComImport]
[Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IObjectSafety
{
[PreserveSig]
int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions);
[PreserveSig]
int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions);
}
[ComImport]
[Guid("37D84F60-42CB-11CE-8135-00AA004BB851")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPersistPropertyBag
{
[PreserveSig]
void InitNew();
[PreserveSig]
void Load (IPropertyBag propertyBag, int errorLog);
[PreserveSig]
void Save (IPropertyBag propertyBag, [InAttribute] bool clearDirty,[InAttribute] bool saveAllProperties);
[PreserveSig]
void GetClassID(out Guid classID);
}
[ComImport]
[Guid("55272A00-42CB-11CE-8135-00AA004BB851")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPropertyBag
{
void Write ([InAttribute] string propName,[InAttribute] ref Object ptrVar);
void Read([InAttribute] string propName, out Object ptrVar, int errorLog);
}
[Guid("D1E40FCE-E964-4dfd-B07E-BDE49D3519A1")]
interface IDownload
{
void InvokeMethod();
}
/// <summary>
/// COM exposed .Net class.
/// </summary>
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("A47C22B1-3CC3-45bc-801E-3FCC4FFD3E45")]
public class Download1 : UserControl, IDownload, IObjectSafety, IPersistPropertyBag
{
private object a;
private Label label1;
private string aa = "load not called";
public Download1()
{
InitializeComponent();
}
// Constants for implementation of the IObjectSafety interface.
private const int INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001;
private const int INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002;
private CheckBox checkBox1;
private Button button1;
private const int S_OK = 0;
/// <summary>
/// COM exposed Method.
/// </summary>
public void InvokeMethod()
{
MessageBox.Show("ClientSide Component invoked sucessfully!!", "ClientSide Component", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
void IPersistPropertyBag.InitNew() { }
void IPersistPropertyBag.GetClassID(out Guid classID) { classID = new System.Guid("A47C22B1-3CC3-45bc-801E-3FCC4FFD3E45"); }
void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog)
{
aa = "load called";
object value;
propertyBag.Read("Server",out value,errorLog);
Debug.Write((string)value);
a = (string)value;
}
void IPersistPropertyBag.Save(IPropertyBag propertyBag, [InAttribute] bool clearDirty, [InAttribute] bool saveAllProperties){}
// Implementation of the IObjectSafety methods.
int IObjectSafety.GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
{
pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
return S_OK; // return S_OK
}
int IObjectSafety.SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions)
{
return S_OK; // return S_OK
}
private void InitializeComponent()
{
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(337, 91);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(325, 153);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(102, 27);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(197, 220);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// Download1
//
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkBox1);
this.Name = "Download1";
this.Size = new System.Drawing.Size(700, 392);
this.ResumeLayout(false);
this.PerformLayout();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = aa;
Debug.Write("d13123sfadsfsdafdsafa");
if (this.checkBox1.Checked == true)
{
this.checkBox1.Checked = false;
this.checkBox1.Text = "1231231afas23123something hand written";
}
else
{
this.checkBox1.Checked = true;
this.checkBox1.Text =(string)a;
}
}
}
}
notice that in the button event i try to get even an info that the load was called but the aa value never changes from "not called