[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Type of System.__ComObject

barker7

2/26/2007 8:42:00 PM

I have created an IDocHostUIHandler class that I pass to the
AXWebBrowser class. Part of this interface is the callback method
"ShowContextMenu". It is called when the right mouse button is
clicked.

My question revolves around getting the Type of the pDispReserved
argument:

public uint ShowContextMenu(uint dwID, ref tagPOINT ppt, object
pcmdtReserved, object pdispReserved)
{
Write(string.Format("Context menu on: {0}",
pdispReserved.GetType().ToString()));

if (pdispReserved is HTMLAnchorElementClass)
{
// create the menu
.....
return 0;
}
return 1

}

Sometimes the type is"System.__ComObject", and other times is is of
type "HTMLAnchorElementClass". In both cases the user is right
clicking the same object on the browser.

Can someone explain why the browser would be passing me a
System.__ComObject object in stead of the HTMLAnchorElementClass
object?

Thanks

Mitch

Thanks

2 Answers

(Mattias Sjögren)

2/27/2007 6:37:00 AM

0

>Can someone explain why the browser would be passing me a
>System.__ComObject object in stead of the HTMLAnchorElementClass
>object?

__ComObject is what the CLR defaults to when it can't determine a more
appropriate type for a RCW object. You may still be able to get a
HTMLAnchorElementClass instance by using Marshal.CreateWrapperOfType.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

BrianH

3/14/2007 7:08:00 PM

0

On a similar subject: How can you tell at run time what the actual type
of a System.__ComObject is? I deal with a structure with a
System.__ComObject property that can be one thing or another. I haven't
found a way to tell which type of thing it is without trying to access a
property in one of them which generates and exception if the object is
actually the other type. I catch the exception and go on, but surely
there is a better way. What is it?

Thanks
..NetNewbie (BrianH)

Mattias Sjögren wrote:
>> Can someone explain why the browser would be passing me a
>> System.__ComObject object in stead of the HTMLAnchorElementClass
>> object?
>
> __ComObject is what the CLR defaults to when it can't determine a more
> appropriate type for a RCW object. You may still be able to get a
> HTMLAnchorElementClass instance by using Marshal.CreateWrapperOfType.
>
>
> Mattias
>