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

Disable right-click context nenu in a HTML dialog based application

Posted on 2003-10-23
6
360 Views
Last Modified: 2013-11-20
Although there are many similar questions asked on EE I have scanned through many of them and haven’t found an answer to my question. I’ve made a dialog based wizard-style application which inherits from CmultiPageDHtmlDialog. I want to prevent the user from displaying the right-click context menu. The main reason is so that they don’t navigate without using by navigation buttons.

Any suggestions? Thanks!
0
Comment
Question by:wjdashwood
6 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 25 total points
ID: 9609014
You could override the 'OnRButtonDown()'  handler to do nothing...
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 275 total points
ID: 9613507
And also prevent pressing *BACKSPACE*
For that you can filter these keypresses in the "PreTranslateMessage" function like

BOOL CmultiPageDHtmlDialogEx::PreTranslateMessage(MSG* pMsg)
{
      if ( pMsg->hwnd == m_hHTMLWnd &&
             pMsg->message == WM_KEYDOWN &&
             pMsg->wParam == VK_BACK )
      {
            return FALSE;
      }

      return CDialog::PreTranslateMessage(pMsg);
}

Rosh :)
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9613520
I have never used the CmultiPageDHtmlDialog so the following may not work.

In your dlg override the PreTranslateMessage fn.
then add
      if(pMsg->message == WM_RBUTTONDOWN)  //possibly also trap WM_RBUTTONUP
        return TRUE;
returning true tells the app it has been handled - so it is hopefully not passed on and generates the context menu
0
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.

 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9613550
Ooops, ite "return TRUE"
Rosj :o)
0
 

Author Comment

by:wjdashwood
ID: 9614425
Thanks everyone for your contributions! Roshmon’s code worked perfectly except I don’t know what the equivalent of m_hHTMLWnd is in my app. Why do I need this line (pMsg->hwnd == m_hHTMLWnd) and how do I find the correct vairable name in my app?

Hopefully I'll share some points out this evening; I'm on dial-up at moment :(

Thanks!
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 50 total points
ID: 9616092
The m_hHTMLWnd is the HWND of your dialog  (GetSafeHwnd() fn will return it)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 51
Separate into files by filename 12 87
method notes when mouse over in eclipse 5 87
firstChar challenge 13 119
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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