Solved

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

Posted on 2003-10-23
6
385 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
[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
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
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 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: 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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

705 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