[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 580
  • Last Modified:

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.
0
vvm101
Asked:
vvm101
  • 5
  • 4
1 Solution
 
chensuCommented:
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
0
 
vvm101Author Commented:
This example explains the way to disable default menu. But I don't understand how to implement my own menu.
0
 
chensuCommented:
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
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
vvm101Author Commented:
I do not understand where CMenu standard procedure must be called.
0
 
chensuCommented:
In the CCustomControlSite::XDocHostUIHandler::ShowContextMenu function (custsite.cpp).
0
 
vvm101Author Commented:
Is it possible to create my own context menu directly in CHTMLView, without implementation IDocHostUIHandler ?
0
 
chensuCommented:
No, you have to implement IDocHostUIHandler. CHTMLView uses the Web Browser control.
0
 
vvm101Author Commented:
But I am looking for a solution without IDocHostUIHandler implementation.
0
 
vvm101Author Commented:
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;
}
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now