Contextmenu on ActiveX control

I have a WebBrowser as ActiveX control on a window. I would like to implement my own contextual menu. Is this possible?

The OLEContainer is a rectcontrol ; it supports http://documentation.xojo.com/index.php/RectControl.ConstructContextualMenu

Hi Michel,

It should… but it doesn’t. It displays the native object menu (IE).

[quote=117964:@Alexander van der Linden]Hi Michel,

It should… but it doesn’t. It displays the native object menu (IE).[/quote]

I will not be back to the PC for a while, but I would try to see if OLEContainer supports mouseDown, and in MouseDown, isContextualClick.

Then maybe you can shortcut the IE contextual menu by displaying yourself the contextual menu and returning true. Something like :

Function MouseDown(X As Integer, Y As Integer) As Boolean
If isContextualClick Then
  dim base as new MenuItem
  // Add some items
  base.Append( New MenuItem( "Test 1" ) )
  base.Append( New MenuItem( "Test 2" ) )
  base.Append( New MenuItem( "Test 3" ) )
  
  // Add a Separator
  base.Append( New MenuItem( MenuItem.TextSeparator ) )
  
  // Add a sub menu
  Dim submenu As New MenuItem( "SubMenu" )
  submenu.Append( New MenuItem( "SubMenu Test 1" ) )
  submenu.Append( New MenuItem( "SubMenu Test 2" ) )
  submenu.Append( New MenuItem( "SubMenu Test 3" ) )
  base.Append( submenu )
  
  // Add a Separator
  base.Append( New MenuItem( MenuItem.TextSeparator ) )
  
  Dim m as MenuItem
  m=base.Popup
return true
end if
  
End Function

In a similar way to how Michel describes, try my classContextualMenu on github. Let me know how you go.

https://github.com/CharlieXojo/classContextualMenu

Alexander,

I just looked at the problem on the PC, and am sorry, I did not realize there was no MouseDown event available. Then I wanted to use JavaScript to tap directly into the DOM, and no ExecuteJavaScript.

Unfortunately, I do not see what to do in such a case. Please forget what I posted, it is irrelevant.

The ConstructContextualMenu event does fire, but only when nothing has been loaded into the control :frowning:

Exactly… there is no MouseDown event.

[quote=117991:@Mike Charlesworth]In a similar way to how Michel describes, try my classContextualMenu on github. Let me know how you go.

https://github.com/CharlieXojo/classContextualMenu[/quote]

There is no MouseDown event. I tried to create a Window Contextmenu with a check wether the WebBrowser control has focus but that didn’t work. Unfortunately.

You maybe able to inject JavaScript through the URL and use the onclick event to display something else. But I am not familiar enough with the IE ActiveX control to assist much more.