Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • 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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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