Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to add/modify contextmenu of URLPresenter/IWebBrowser2 ?

98 views
Skip to first unread message

Eno

unread,
May 22, 2008, 5:06:07 AM5/22/08
to
Hi,
Firefox had every control of the browser activities, including the
browser contents editing, context menus modification, web 2.0
integration, addons etc, all these functions are quite fasicinating and
promising, I wondered whether Dolphin can achieve the same capacity,
using his URLPresenter/IWebBrowser2 ( exposing more functions of the
wrapped control ) ?
First of all, can we modify/custom URLPresenter's context menus (
which is IE one by default ) to add new menuitem to trigger my own
search function etc ?

Best regards

Udo Schneider

unread,
May 22, 2008, 5:09:13 PM5/22/08
to
Eno,

> First of all, can we modify/custom URLPresenter's context menus (
> which is IE one by default ) to add new menuitem to trigger my own
> search function etc ?

I'm not quite sure whether it's possible to customize the default menu
dynamically. You can do it globally (see
http://msdn.microsoft.com/en-us/library/aa741313(VS.85).aspx#Controlling_the_Cont
for more information) by tweaking the Registry Entries.

You can however replace it completely.

URLPresenterWithContextMenu (in package "US Internet Explorer
Extensions") allows you to control which context menu is displayed in a
WebControl:

* If the presenters view #allowContextMenu aspect is false no
context menu will be shown. Neither a custom one nor the default one.
* If the presenters view #allowContextMenu aspect is true it depends
on #contextMenu. If #contextMenu is not nil it will be displayed. If it
is nil the default one will be used.

Behind the scenes this presenter implements the
IDocHostUIHandlerDispatch interface to get queries for some UI events.
The interesting one here is ShowContextMenu() which allows you to
allow/prevent the display of the default context menu. I'm using this
method for the logic using #allowContextMenu and #contextMenu.

However for using this presenter no digging into COM is needed. Simply
use #allowContextMenu and #contextMenu as written above.

You can download the most recent version of my goodies here:
http://readthesourceluke.blogspot.com/

Hope this helps.

CU,

Udo

Eno

unread,
May 23, 2008, 11:32:49 PM5/23/08
to
Hi Udo:

Udo Schneider wrote:
> Behind the scenes this presenter implements the
> IDocHostUIHandlerDispatch interface to get queries for some UI events.
> The interesting one here is ShowContextMenu() which allows you to
> allow/prevent the display of the default context menu. I'm using this
> method for the logic using #allowContextMenu and #contextMenu.
>

Thanks again for your great help to fill in the missing stones, it
would be better if the #todo are implemented in futher update versions
of your packages.
BTW, another question, could I get the selected text in the browser
from the underlying MSHTML controller ( via IWebBrowser2::get_Document
to get IHtmlDocument2 ?)


Best reguards.

Eno

unread,
May 24, 2008, 4:42:00 AM5/24/08
to
Hi,
I found the following code work as I needed:

URLPresenter>>documentSelection
| browser |
browser := self view controlDispatch.
^browser document selection createRange text.

It's just a quick workout, I think, without creating new
ImpType/IDispatch objects. Formal resolution might be needed.

Best regards.

Udo Schneider

unread,
May 25, 2008, 1:18:22 PM5/25/08
to
Eno,

> Thanks again for your great help to fill in the missing stones, it
> would be better if the #todo are implemented in futher update versions
> of your packages.

The #todo Symbol and the comment are misleading - my mistake. Returning
E_NOTIMPL is perfectly legal for the non-implemented methods in this
interface. It simply tells the caller to use the default processing.
So we only return S_OK for the context menu stuff where we really do
something.

> BTW, another question, could I get the selected text in the browser
> from the underlying MSHTML controller ( via IWebBrowser2::get_Document
> to get IHtmlDocument2 ?)

Just uploaded a new version. URLPresenter now has getSelectedText
methods for your convenience.

CU,

Udo

Udo Schneider

unread,
May 25, 2008, 1:20:11 PM5/25/08
to
Eno,

> It's just a quick workout, I think, without creating new
> ImpType/IDispatch objects. Formal resolution might be needed.

This is fine - I'm doing nothing else in my goodies. However you should
wrap this in an exception handler as the Control throws errors. An
example is calling this method w/o selected text in the browser. This
sometimes throws errors as well.

CU,

Udo

0 new messages