Hi,
There is a lot of stuff on the web about this problem. I searched in
groups.google.com for "dotnet default method" and read some MSDN articles as
well (most pertaining to legacy VB).
Basically, the HTML events require an IDispatch interface to invoke a default,
parameterless method, which C# doesn't support. I tried a bunch of things
using DispIdAttribute, ClassInterfaceAttribute and DispatchWrapper but I
couldn't get it to work. Assignment always throws an InvalidCastException
(presumably because I didn't go as far as implementing IDispatch
In the 2.0 framework I use the HtmlElement.AttachEventHandler method, which
allows me to supply an EventHandler delegate. Unfortunately, I doubt you'll
be able to go that route because the class itself is dependant on the
WebBrowser control, but you might want to take a peek at how it's accomplished
in that class.
--
Dave Sexton
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I did try that.
>
> public delegate void F();
> F f = delegate () { MessageBox.Show ("delegate");};
> IHTMLElement2 h;
> h.attachEvent ("oncut", f);
>
> Maybe the signature is not correct.
>
> I did try passing various other signatures for the delegate.
>
> If you have a specific example that would be great. I am stumped.
> Duane
>
>
> Dave Sexton wrote:
>> Hi,
>>
>> The second parameter is the function pointer. Try passing in a delegate.
>>
>> --
>> Dave Sexton
>>
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have successfully installed a BHO in IE7. Using C#.
>> >
>> > Now I'm trying to figure out how to trap various events. onkeypress,
>> > oncut, oncontextmenu, etc.
>> >
>> > I have tried calling in various IHTMLElement2.attachEvent, but no
>> > success. attachEvent wants two parameters: event name, and object
>> > pdisp.
>> >
>> > I cannot find the correct means to populate pdisp. Or is there another
>> > way to trap events from a BHO and C#?
>> >
>> > Any help would be greatly appreciated.
>> >
>> > Thanks.
>> >
>