Click here to Skip to main content
15,914,488 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sending e-mail from Windows Forms Pin
mikker_1237-May-04 9:03
mikker_1237-May-04 9:03 
GeneralRe: Sending e-mail from Windows Forms Pin
Heath Stewart7-May-04 9:10
protectorHeath Stewart7-May-04 9:10 
GeneralJPEG TO BITMAP Pin
Member 6910895-May-04 14:43
Member 6910895-May-04 14:43 
GeneralRe: JPEG TO BITMAP Pin
mikker_1236-May-04 3:59
mikker_1236-May-04 3:59 
GeneralRe: JPEG TO BITMAP Pin
Member 6910896-May-04 16:35
Member 6910896-May-04 16:35 
GeneralRe: JPEG TO BITMAP Pin
mikker_1237-May-04 9:16
mikker_1237-May-04 9:16 
Generalmouse related problem Pin
Zaffar Kamran5-May-04 13:52
Zaffar Kamran5-May-04 13:52 
GeneralRe: mouse related problem Pin
Heath Stewart5-May-04 14:12
protectorHeath Stewart5-May-04 14:12 
GeneralRe: mouse related problem Pin
Member 6910895-May-04 15:05
Member 6910895-May-04 15:05 
QuestionDatagrid Currency Column?? Pin
DougW485-May-04 12:55
DougW485-May-04 12:55 
AnswerRe: Datagrid Currency Column?? Pin
Heath Stewart5-May-04 14:10
protectorHeath Stewart5-May-04 14:10 
GeneralRe: Datagrid Currency Column?? Pin
DougW485-May-04 14:43
DougW485-May-04 14:43 
GeneralNewline in Label Text Pin
Okeno Palmer5-May-04 12:18
Okeno Palmer5-May-04 12:18 
GeneralRe: Newline in Label Text Pin
Heath Stewart5-May-04 14:07
protectorHeath Stewart5-May-04 14:07 
GeneralRe: Newline in Label Text Pin
Okeno Palmer5-May-04 14:51
Okeno Palmer5-May-04 14:51 
GeneralMore of column headers filters in custom lisview Pin
machocr5-May-04 10:58
machocr5-May-04 10:58 
GeneralRe: More of column headers filters in custom lisview Pin
Heath Stewart5-May-04 14:02
protectorHeath Stewart5-May-04 14:02 
Generalfish eye images converter Pin
doph5-May-04 8:34
doph5-May-04 8:34 
GeneralStrange TypeLoadException Pin
Broken God5-May-04 5:59
Broken God5-May-04 5:59 
GeneralRe: Strange TypeLoadException Pin
leppie5-May-04 6:52
leppie5-May-04 6:52 
GeneralRe: Strange TypeLoadException Pin
Anonymous5-May-04 7:47
Anonymous5-May-04 7:47 
GeneralRemoving event listeners on IHTMLDocument2 objects Pin
agking5-May-04 5:56
agking5-May-04 5:56 
I am hosting a WebBrowser control, and have a reference to the association document property (IHTMLDocument2 interface). Per Microsoft's guidelines, I have attached events as follows:

private void AttachListeners(IHTMLDocument2 Document) {
HTMLDocumentEvents2_Event iEvent = (HTMLDocumentEvents2_Event)Document;
iEvent.onmouseover += new HTMLDocumentEvents2_onmouseoverEventHandler(Element_onmouseover);
iEvent.onmouseout += new HTMLDocumentEvents2_onmouseoutEventHandler(Element_onmouseout);
}

I have another method, to remove the event listeners:

private void DetachListeners(IHTMLDocument2 Document) {
HTMLDocumentEvents2_Event iEvent = (HTMLDocumentEvents2_Event)Document;
iEvent.onmouseover -= new HTMLDocumentEvents2_onmouseoverEventHandler(Element_onmouseover);
iEvent.onmouseout -= new HTMLDocumentEvents2_onmouseoutEventHandler(Element_onmouseout);
}

My problem is that when I remove the listeners, it actually causes them to fire twice! If I try to call DetachListeners a second time, I get an error "object reference not set to an instance of an object" (I would expect some sort of error because I'm theoretically removing an event that has already been removed).

My guess is that there is a bug here in the interop stuff, where the "-=" operator is removing the event from the .net view of the world but adding it again in the COM level.

Anyone had this problem before, or know where to look?

Anthony King
GeneralDLL Help Pin
goldoche5-May-04 5:54
goldoche5-May-04 5:54 
GeneralRe: DLL Help Pin
Heath Stewart5-May-04 6:59
protectorHeath Stewart5-May-04 6:59 
GeneralXmlDocument, SOAP& Namespaces Pin
MrEyes5-May-04 5:40
MrEyes5-May-04 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.