Solved

CHTMLView ContextMenu

Posted on 2002-03-21
7
509 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 300 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 47
child constructor and parent constructor, overriding and overloading 6 93
zeroFront challenge 7 121
I could not set window to top 4 40
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

735 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