Solved

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

Posted on 2003-10-23
6
337 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 56
Process filename extension 3 172
Looking for a specific application/software 2 104
unable to delete all specified values regedit 38 283
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

12 Experts available now in Live!

Get 1:1 Help Now