CodeItBetter Programming Another VB Programming Blog

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

Related posts:

  1. How to add PopUp Menu to TreeView
  2. How to check on which word the Mouse hover in Rich Text Box
  3. How to scan List Box for the text in TextBox
  4. How to set Text Box Left and Right Margins
  5. How to Paste the Picture from PictureBox/Clipboard to Rich Text Box
  6. How to show custom popup menu in a text box
  7. How to insert a picture into Rich Text box
  8. How to count number of lines in a Text box
  9. How to set List View Text Background Color
  10. How to select the text in a textbox and send it to the clipoard.

Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.