Home » Controls » How to add Pop Up menu to Text Box Control
How to add Pop Up menu to Text Box Control
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 'Controls - How to add Pop Up menu to Text Box Control Option Explicit 'Add a Text Box to your form. Add a Menu (Name it MyMenu) and at least one Sub Menu. Private Const WM_RBUTTONDOWN = &H204 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Sub OpenContextMenu(FormName As Form, MenuName As Menu) Call SendMessage(FormName.hwnd, WM_RBUTTONDOWN, 0, 0&) FormName.PopupMenu MenuName End Sub Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbRightButton Then Call OpenContextMenu(Me, Me.MyMenu) End Sub |
Enjoy this article?
Filed under: Controls
Leave a comment