Link to home
Start Free TrialLog in
Avatar of vvm101
vvm101

asked on

Context menu in CHTMLView-based application

My application based on CHTMLView class, and I need to create my own context menu instead of default context menu for this view. I am trying to implement it in WM_CONTEXTMENU handler, but application does not reach this point.
Avatar of chensu
chensu
Flag of Canada image

You need to implement the IDocHostUIHandler interface. See

Driller (MFC) Sample
http://msdn.microsoft.com/downloads/c-frame.htm?953938653415#/downloads/samples/internet/browser/driller/default.asp
Avatar of vvm101
vvm101

ASKER

This example explains the way to disable default menu. But I don't understand how to implement my own menu.
You can use CMenu::TrackPopupMenu to show your menu.

Building a Dynamic Menu for TrackPopupMenu
http://support.microsoft.com/support/kb/articles/Q105/1/69.asp

HOWTO: Mirror Main Menu with TrackPopupMenu()
http://support.microsoft.com/support/kb/articles/Q99/8/06.ASP
Avatar of vvm101

ASKER

I do not understand where CMenu standard procedure must be called.
In the CCustomControlSite::XDocHostUIHandler::ShowContextMenu function (custsite.cpp).
Avatar of vvm101

ASKER

Is it possible to create my own context menu directly in CHTMLView, without implementation IDocHostUIHandler ?
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vvm101

ASKER

But I am looking for a solution without IDocHostUIHandler implementation.
Avatar of vvm101

ASKER

If current implementation allows, it is possible to override default menu in CHTMLView-based application using PreTranslateMessage(MSG* pMsg) :

if ( pMsg->message == WM_RBUTTONUP )
{
   POINT pt = pMsg->pt;
   CWnd::ScreenToClient(&pt);
   ShowMyContextMenu(pt);
   return true;
}