VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

This code allows you to change the default right click menu in a text box

bader  (7 Submissions)   Miscellaneous   VB 6.0   Unknown Difficulty   Sat 8th January 2000   Mon 8th February 2021

This code allows you to change the default right click menu in a text box

API Declarations



Public Const GWL_WNDPROC = (-4)
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Const WM_CONTEXTMENU = &H7B

Public origWndProc As Long

Public Sub SetHook(hwnd, bSet As Boolean)
If bSet Then
origWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf AppWndProc)
ElseIf origWndProc Then
Dim lRet As Long
lRet = SetWindowLong(hwnd, GWL_WNDPROC, origWndProc)
End If
End Sub

Public Function AppWndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case WM_CONTEXTMENU
Form1.PopupMenu Form1.mnuBP
AppWndProc = 0
Exit Function
End Select
AppWndProc = CallWindowProc(origWndProc, hwnd, Msg, wParam, lParam)
End Function


Rate This code allows you to change the default right click menu in a text box (1(1 Vote))
This code allows you to change the default right click menu in a text box.bas

This code allows you to change the default right click menu in a text box Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters