Solved

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

Posted on 2003-10-23
6
322 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
Comment Utility
You could override the 'OnRButtonDown()'  handler to do nothing...
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 275 total points
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
Ooops, ite "return TRUE"
Rosj :o)
0
 

Author Comment

by:wjdashwood
Comment Utility
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
Comment Utility
The m_hHTMLWnd is the HWND of your dialog  (GetSafeHwnd() fn will return it)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now