Solved

Can system right-click invoked pop-up menu be disabled?

Posted on 1998-12-04
5
142 Views
Last Modified: 2012-05-04
Is it possible with VB5 to disable the system pop-up menu that appears when right-clicking on a text box?  The Paste option allows the user to circumvent validation in my app.  If not, can an application be instructed to ignore right-mouse clicks?  
0
Comment
Question by:craigdawson
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:traygreen
ID: 1448254
Try this in the mouse down event for the controls in question...

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button = 2 And Shift = 0 Then
      Button = 0
      MsgBox "Mouse Down"
   End If

End Sub

or put the code in a global routine
Public sub SupressPopup(Button As Integer, Shift As Integer)
   If Button = 2 And Shift = 0 Then
      Button = 0
      MsgBox "Mouse Down"
   End If
end sub

and put ...
Call SupressPopup(Button, Shift) in the mousedown events

0
 

Author Comment

by:craigdawson
ID: 1448255
Popup menu still appears.
0
 
LVL 3

Accepted Solution

by:
traygreen earned 50 total points
ID: 1448256
Are you getting the message "Mouse Down"?  If not you do not have the code in all of the controls.  You need to put the code in each of the controls on which you wish to suppress the popup menu.
Email me your form if you would like and I can take a look and see if there is anything weird going on. (traygreen@hotmail.com)
0
 

Author Comment

by:craigdawson
ID: 1448257
Sorry, I should have been more clear.  It works as long as the msgbox is there but not once that line is removed.  I can't have message boxes popping up on every right-click so I still have no solution.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1448258
CraigDawson,
    What I've had to do in the past is create my own popup menu and use it in place of the default popup menu. It's usually just a bogus menu item (HELP, for example). To do this, create a menu item, we'll call it mnuTest for this example. Click off "visible", so that it doesn't show in your application. Then you must have at least one subitem, so create a menu item underneath mnuTest called mnuHelp. It must be visible (too bad, too, because that would solve our problem).

Then, in your TextBox MouseDown event, put this:

If Button = 2
    Text1.Enabled = False
    PopupMenu mnuTest
    Text1.Enabled = True
    Text1.SetFocus
End-if

Your new popupmenu will display instead of the default, and it won't have Paste. You'll obviously have to display the help file, or whatever bogus thing you did put on your menu, but it effectively prevents them from using the Paste command, and doesn't look bad. It's an alternative to preventing all right mouse clicks.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
VBA saving file message display 5 73
How to debug this code 7 64
How to read File Date Created using VB6 8 52
Powerpoint 2013: Change cell reference in excel link 3 83
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

829 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