Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Context menu in CHTMLView-based application

Posted on 2000-03-24
9
559 Views
Last Modified: 2009-07-29
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
Comment
Question by:vvm101
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2655366
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
 

Author Comment

by:vvm101
ID: 2655388
This example explains the way to disable default menu. But I don't understand how to implement my own menu.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2655455
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 

Author Comment

by:vvm101
ID: 2655973
I do not understand where CMenu standard procedure must be called.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2656090
In the CCustomControlSite::XDocHostUIHandler::ShowContextMenu function (custsite.cpp).
0
 

Author Comment

by:vvm101
ID: 2656578
Is it possible to create my own context menu directly in CHTMLView, without implementation IDocHostUIHandler ?
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 2657094
No, you have to implement IDocHostUIHandler. CHTMLView uses the Web Browser control.
0
 

Author Comment

by:vvm101
ID: 2666617
But I am looking for a solution without IDocHostUIHandler implementation.
0
 

Author Comment

by:vvm101
ID: 2684329
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question