472,805 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Consuming managed events within Internet Explorer

Hello and thank you in advance for your help.

Can anyone think of a reason why this code would work properly on one PC,
but not another?

I've got a System.Windows.Forms.UserControl that products events which I
want to consume (sink) within Internet Explorer.

I'm following the instructions at:
ms-http://support.microsoft.com/default.aspx?kbid=313891.

On one computer, Internet Explorer can call methods on the UserControl and
can sink events generated by this managed code.

Using the same code on another computer, Internet Explorer can call methods
on this UserControl, but can not sink the events this managed code is
generating.

The UserControl is written in Visual Studio 2003 using C#. The framework
version is "v1.1.4322" on both computers.

The operating system on the computer where the code works (call methods on
the UserControl + sink events generated by the UserControl in IE) is: XP sp2
+ all the latest Windows Updates.

The operating system on the computer where the code does NOT work (call
methods on the UserControl only) is: XP sp1 + all the latest Windows Updates.

Here's a copy of the C# UserControl code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace TestWUCEventer
{
#region EventDelegates

/// <summary>
/// Delegate invoked when a NOTIFY event occurs.
/// </summary>
public delegate void sssNotifyEventHandler(string getResultXml);

/// <summary>
/// Delegate invoked when a SURVEY event occurs.
/// </summary>
public delegate void sssSurveyEventHandler();

#endregion

#region Outgoing COM Interfaces

/// <summary>
/// This interface is for raising SDK events to COM clients.
/// </summary>
[GuidAttribute("4AF6A157-AD81-4da3-8FF7-1AD1135D0645")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)]
public interface ISDKEvents
{
/// <summary>
/// Raise the NOTIFY event to COM clients.
/// </summary>
/// <param name="getResultXml">The string that is passed with the NOTIFY
event.</param>
[DispIdAttribute(0x60020010)]
void NotifyEvent(string getResultXml);

/// <summary>
/// Raise a SURVEY event to COM clients.
/// </summary>
[DispIdAttribute(0x60020011)]
void SurveyEvent();
}

#endregion

#region Incomming COM Interfaces

public interface ISDKClient
{
/// <summary>
/// Raise the NOTIFY event.
/// </summary>
/// <param name="IncludeWithNotify">Data passed with the NOTIFY
event.</param>
void RaiseNotifyEvent(string IncludeWithNotify);

/// <summary>
/// Raise the SURVEY event.
/// </summary>
void RaiseSurveyEvent();

/// <summary>
/// Simple test for accessing Windows Control Library method from web page
displayed in IE.
/// </summary>
/// <returns>Hello World</returns>
string TestMessage();

/// <summary>
/// Start the timer which automatically raises events.
/// </summary>
void StartTimer();
}

#endregion

/// <summary>
/// Summary description for UserControl1.
/// </summary>
[ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ISDKEvents))]
public class EventGenerator : System.Windows.Forms.UserControl, ISDKClient
{
#region EventsRaised

/// <summary>
/// Event is raised when a SURVEY occurs.
/// </summary>
public event sssSurveyEventHandler SurveyEvent;

/// <summary>
/// Event raised when a NOTIFY occurs.
/// </summary>
public event sssNotifyEventHandler NotifyEvent;

#endregion

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Timer eventTimer = null;
private enum EventType { SURVEY, NOTIFY };
private EventType lastEvent = EventType.SURVEY;

public EventGenerator()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization after the InitComponent call

// Start our eventTimer.
eventTimer = new Timer();
eventTimer.Tick += new EventHandler(eventTimer_Tick);
eventTimer.Interval = 2000;
eventTimer.Enabled = false;
// eventTimer.Start();
}

/// <summary>
/// Start a timer that automatically raises events.
/// </summary>
public void StartTimer()
{
eventTimer.Enabled = true;
eventTimer.Start();
}

/// <summary>
/// Simple test for accessing Windows Control Library method from web page
displayed in IE.
/// </summary>
public string TestMessage()
{
return ("Hello World");
}

/// <summary>
/// Call RaiseNotifyEvent to cause a NOTIFY event to be raised.
/// </summary>
/// <param name="IncludeWithNotify">Any string to include as the data of
the NOTIFY event.</param>
public void RaiseNotifyEvent(string IncludeWithNotify)
{
try
{
if (NotifyEvent != null)
{
NotifyEvent(IncludeWithNotify);
}
}
catch (Exception exc)
{
throw (exc);
}
}

/// <summary>
/// Call RaiseSurveyEvent to cause a SURVEY event to be raised.
/// </summary>
public void RaiseSurveyEvent()
{
try
{
if (SurveyEvent != null)
SurveyEvent();
}
catch (Exception exc)
{
throw (exc);
}
}

private void eventTimer_Tick(object sender, EventArgs e)
{
// Stop the timer until we're done with this method.
eventTimer.Stop();

if (lastEvent == EventType.SURVEY)
{
// Raise a NOTIFY event.
RaiseNotifyEvent("This is a test string.");

// Record the last event raised.
lastEvent = EventType.NOTIFY;
}
else
{
// Raise a NOTIFY event.
RaiseSurveyEvent();

// Record the last event raised.
lastEvent = EventType.SURVEY;
}

// Start the timer again.
eventTimer.Start();
}

/// <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()
{
//
// EventGenerator
//
this.Name = "EventGenerator";
this.Size = new System.Drawing.Size(1, 1);

}
#endregion

}
}

Here's a copy of the web page that runs in Internet Explorer:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="EventTesterWeb.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" id="SurveyEventHandler" event="SurveyEvent"
for="ssClient">
alert("SURVEY event");
</script>
<script language="javascript" id="NotifyEventHandler"
event="NotifyEvent(notifyResultXml)" for="ssClient">
alert("NOTIFY event: " + notifyResultXml);
</script>
<script id="WebPageScript" language="javascript">
function OnWebPageLoad()
{
// Try calling the test method.
document.all.lblDisplayMessage.outerText = ssClient.TestMessage();
}
function StartTimer()
{
ssClient.StartTimer();
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="javascript:OnWebPageLoad();">
<OBJECT id="ssClient"
classid="http:TestWUCEventer.dll#TestWUCEventer.Ev entGenerator" height="32"
width="32">
</OBJECT>
<form id="Form1" method="post" runat="server">
<asp:Label id="lblDisplayMessage" style="Z-INDEX: 101; LEFT: 8px;
POSITION: absolute; TOP: 8px"
runat="server" Width="240px">Nothing yet...</asp:Label>
<input type="button" value="Start Timer"
onclick="javascript:StartTimer();" />
</form>
</body>
</HTML>

Apr 17 '06 #1
1 3445
Have you compared the Internet Explorer security settings on the two
machines? You may find the one that doesn't work is due to a security
restriction or setting which isn't in force on the machine where your
code does work.

Other than that, try making sure the platforms are as similar as
possible - it could be an SP2 / SP1 thing.

Cheers, M

Apr 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
3
by: Rick Strahl [MVP] | last post by:
I'm working on an app that's using the WebBrowser control. I got the control working fine, hooking to the document object. But I've run into a major issue with hooking the Document events....
0
by: Kerem Gümrükcü | last post by:
Hi, i use the internet explorer embeeded in SHDocVw.dll but my WebBrowser Object does not fire any event. is this a Bug and how can i "receive" events from my Browser class...? Everything...
5
by: | last post by:
I'm having difficulty embedding a managed C++ control in Internet Explorer. I'm using the same object syntax in the html as I would for a c# control, but IE doesn't seem to find the control in the...
7
by: Roberto Perez via .NET 247 | last post by:
Hello all and thank you in advance. We have several old applications in Cobol, Centura, etc that needs to be converted to .NET In order to save time our plan is to create web services and call...
7
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have...
2
by: niels.froehling | last post by:
Hy; I'm stucked in modifying events to make a multi-select select-input being additive/subtractive only. Because I should offer a solution similar to that select for DAUs (aka. MostIdioticUser)...
2
by: Filippo Bettinaglio | last post by:
Hi, I use, VS2005 C# I have a Windows Forms UserControl hosted within Internet Explorer According to MIcrosoft documentation: ...
0
by: jonathan.beckett | last post by:
I have been working on a client project recently that is using winforms ..NET user controls within web pages in Internet Explorer, and need to find out how to make the user control communicate back...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.