Solved

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

Posted on 1998-12-04
5
144 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
[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
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

691 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