?
Solved

CHTMLView ContextMenu

Posted on 2002-03-21
7
Medium Priority
?
520 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
[X]
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
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:peterdownes
ID: 6887320
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 1200 total points
ID: 6888123
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
ID: 6973446
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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 49

Expert Comment

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

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7011107
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
ID: 7011434
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
ID: 7022783
Thanks. :)
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

719 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