Solved

CHTMLView ContextMenu

Posted on 2002-03-21
7
496 Views
Last Modified: 2013-11-20
I am using VC++6.0, Created a SDI App based on CHTMLVIEW


I tryed the following

void CMyBrowserView::OnContextMenu(CWnd* pWnd, CPoint point)
{
     CMenu Menu;

     // Get a pointer to the menu
     Menu.LoadMenu(IDR_CONTEXTMENU);
     
     CMenu *mMenu;
     // Get a pointer to the submenu
     mMenu = Menu.GetSubMenu(0);
     // Open it as a context menu
     mMenu->TrackPopupMenu(TPM_LEFTALIGN + TPM_LEFTBUTTON,
          point.x, point.y, pWnd, NULL);    
}

and

void CMainFrame::OnContextMenu(CWnd* pWnd, CPoint point)
{
     CMenu Menu;

     // Get a pointer to the menu
     Menu.LoadMenu(IDR_CONTEXTMENU);
     
     CMenu *mMenu;
     // Get a pointer to the submenu
     mMenu = Menu.GetSubMenu(0);
     // Open it as a context menu
     mMenu->TrackPopupMenu(TPM_LEFTALIGN + TPM_LEFTBUTTON,
          point.x, point.y, pWnd, NULL);          
}

and still it didn't popup my contextmenu. Any Ideas on how to fix that?

0
Comment
Question by:MarkOttoSmith
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:peterdownes
Comment Utility
TPM_LEFTALIGN + TPM_LEFTBUTTON

should be

TPM_LEFTALIGN | TPM_LEFTBUTTON

But I don't think this is the only problem.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 300 total points
Comment Utility
General tip:  First step in diagnosing a problem like this is to see if your message handkler is being called.  Place something like this

   MessageBox("OnContextMenu called!");
at the top of the function.  I'll wait...

So now, you know that your handler is not being called.  That is because the Webbrowser intercepts all clicks made in it.  Creating a custom context-menu handler for a WebBrowser controls is quite tricky.  The steps are described here:

http://207.46.197.63/gomsuri.asp?n=1&c=rp_Results&target=http://support.microsoft.com/support/kb/articles/Q236/3/12.ASP

It tells how to disable it, but at the same location on the code where they disable it, you can pop up a menu of your own.


Incidently, if you simply want to disable the contxt menu, there is an easier way.  Override PreTranslateMessage and use code like this  

BOOL CSdiHtmlView::PreTranslateMessage(MSG* pMsg)
{
     if (pMsg->message == WM_RBUTTONDOWN) {
          MessageBox("Please don't press that button any more!");
          return 1;
     }
     
     return CHtmlView::PreTranslateMessage(pMsg);
}

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Please remain active in your questions here and provide feedback to the Experts who help you.  If more is needed, let them know.
Thank you,
Moondancer - EE Moderator
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi MarkOttoSmith,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
MarkOttoSmith has not responded to my request of 4/27/02, nor to help posted by Experts.  It looks like this is left in my hands to finalize.

Expert input is appreciated here so I can be fair in the finalization of this question.

Thanks,

Moondancer - EE Moderator
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Moondancer,
Although I billed my comment as a 'general tip' it also included a complete and specific solution to the problem.  I submit that unless MarkOttoSmith requests clarification, I desrve credit for that answer.

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Thanks. :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now