0

I use a proprietary IDE that is part of a large software package. At its core, however, C# is used as the language. Most .Net components and classes can be used. I can use it to create my own functions / WinForms, which are then integrated into an ERP system. This means that you can expand this system yourself. This is quite well implemented but there is no documentation and the support is also poor at this point. That's why I'm trying my luck here. Maybe someone can help.

I am currently programming a WinForms window that contains a WebBrowser control (wb). I'm pretty sure this is IE. I can programmatically create and include HTML code via MemoryStream (ms):

ms.Write(bytes, 0, bytes.Length);
wb.DocumentStream = ms;

It all works very well. Now I want to get events from the browser and have had the IDE create event handlers for this:

try {       
  wb.Click += new EventHandler(wb_Click);
  ...} etc.
public void wb_Click (object sender, EventArgs e)
  { }

The compiler shows no errors. During the execution I get the error message: The Click event is invalid for this ActiveX control. What could trigger this error? W. Wolf

wwolf
  • 1
  • 2
  • 1
    "I'm pretty sure this is IE." - **it is** (specifically, `MSHTML.dll`) which is currently frozen-in-time around 2013 (i.e. IE11) – Dai Dec 16 '21 at 10:04
  • 1
    "I use a proprietary IDE that is part of a large software package. [...] but there is no documentation and the support is also poor at this point" - That doesn't narrow it down: I can think of at least a dozen fitting this description. – Dai Dec 16 '21 at 10:05
  • https://stackoverflow.com/questions/9110388/web-browser-control-how-to-capture-document-events – Hans Passant Dec 16 '21 at 13:57

1 Answers1

0

Thanks for your tips! I was able to solve this with the following code:

...
HtmlElementCollection elements = wb.Document.GetElementsByTagName("span");
    for (int n = 0; n < elements.Count;n++)
    {
        elements[n].Click += new HtmlElementEventHandler(el_Click);
    }
...
public void el_Click (object sender, HtmlElementEventArgs e)
{
    HtmlElement el = (HtmlElement) sender;
    ShowInfo(el.Id);
}

I can continue to work with it.

wwolf
  • 1
  • 2