|
|
|
When you right-click a TextBox control, Windows sends it a WM_CONTEXTMENU message, to which VB reacts by displaying the default Edit popup menu, that contains editing commands such as Cut, Copy, Paste, and Select All. Using a subclassing technique you can easily trap this message before it reaches the original window procedure, and suppress the default Edit menu or substitute it with a custom popup menu. Thanks to the MsgHook DLL this is a trivial task: |
Click here to copy the following block |
Const WM_CONTEXTMENU = &H7B
Dim WithEvents TextBoxHook As MsgHook
Private Sub Form_Load() Set TextBoxHook = New MsgHook TextBoxHook.StartSubclass Text1.hWnd End Sub
Private Sub TextBoxHook_BeforeMessage(uMsg As Long, wParam As Long, _ lParam As Long, retValue As Long, Cancel As Boolean) If uMsg = WM_CONTEXTMENU Then PopupMenu mnuPopup Cancel = True End If End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|