Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 6, 1997

Disable the Default Popup Menu on Text Boxes

Some controls in VB4 and VB5, such as the TextBox control, have a default context menu that appears when you right-click on the control. If you want to pop up your own context menu, no property or method of those controls exists to disable the default behavior. To solve this problem, place code in the Mouse_Down event, which disables the target control. Pop up your context menu, and then re-enable the control. Here's the method in PopContextMenu:
 
Sub PopContextMenu(argoControl As _
        Control, argoMenu As Control)
                argoControl.Enabled = False
                PopupMenu argoMenu
                argoControl.Enabled = True
End Sub
Call it in the MouseDown event of a text box named Text1 for a menu called MyMenu:
 
Private Sub Text1_MouseDown(Button As _
        Integer, Shift As Integer, X As _
        Single, Y As Single)
                If Button = vbRightButton Then
                        PopContextMenu Text1, MyMenu
                End If
End Sub
William Jordan
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date