Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

CHTMLView ContextMenu

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
MarkOttoSmith
Asked:
MarkOttoSmith
  • 3
  • 3
1 Solution
 
peterdownesCommented:
TPM_LEFTALIGN + TPM_LEFTBUTTON

should be

TPM_LEFTALIGN | TPM_LEFTBUTTON

But I don't think this is the only problem.
0
 
DanRollinsCommented:
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
 
MoondancerCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DanRollinsCommented:
Hi MarkOttoSmith,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
MoondancerCommented:
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
 
DanRollinsCommented:
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
 
MoondancerCommented:
Thanks. :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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