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

CHTMLView ContextMenu

Posted on 2002-03-21
7
508 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
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 105
canBalance challenge 34 96
Detect file exist or not 3 178
Trying to run powershell  in a batch file. How do I do this? 8 105
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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