I have created a context menu when a user right clicks on a link. I've
implemented IDocHostUIHandler and post the menu if the right click
happened on a link:

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
}

On some PC's the first time the user right clicks a link, the above
method is calles, but the menu is NOT posted because the type of the
pDispReserved object appears to be "System.__ComObject" instead of
"HTMLAnchorElementClass".

Why is the pdispReserved object sometimes "System.__ComObject". Can
anyone explain what "System.__ComObject" is?

Thanks

Mitch

Re: IDocHostUIHandler ShowContextMenu problem with one of the args by mh

mh
Mon Feb 26 19:39:16 CST 2007

On Feb 26, 12:01 pm, bark...@yahoo.com wrote:
> I have created a context menu when a user right clicks on a link. I've
> implemented IDocHostUIHandler and post the menu if the right click
> happened on a link:
>
> 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
>
> }
>
> On some PC's the first time the user right clicks a link, the above
> method is calles, but the menu is NOT posted because the type of the
> pDispReserved object appears to be "System.__ComObject" instead of
> "HTMLAnchorElementClass".
>
> Why is the pdispReserved object sometimes "System.__ComObject". Can
> anyone explain what "System.__ComObject" is?
>
> Thanks
>
> Mitch

dwID parameter contains the type of contextmenu. It is one of
CONTEXT_MENU_DEFAULT = 0,
CONTEXT_MENU_IMAGE = 1,
CONTEXT_MENU_CONTROL = 2,
CONTEXT_MENU_TABLE = 3,
// in browse mode
CONTEXT_MENU_TEXTSELECT = 4,
CONTEXT_MENU_ANCHOR = 5,
CONTEXT_MENU_UNKNOWN = 6,
CONTEXT_MENU_IMGDYNSRC = 7,
CONTEXT_MENU_IMGART = 8,
CONTEXT_MENU_DEBUG = 9,
CONTEXT_MENU_VSCROLL = 10,
CONTEXT_MENU_HSCROLL = 11
Use a switch to find out if dwID is equal to CONTEXT_MENU_ANCHOR, show
your menu. If you need additional information in regard to the link,
simply cast pdispReserved to an IHTMLAnchorElement.
IHTMLAnchorElement phref = pdispReserved as IHTMLAnchorElement;
if(phref != null) //....

Hope this helps.