Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y _
As Single)
If Button = 2 Then
Text1.Enabled = False
Text1.Enabled = True
PopupMenu mymenu
End If
End Sub
復(fù)制代碼
方法二:回調(diào)函數(shù)
module:
Option Explicit
Public OldWindowProc As Long ' 保存默認(rèn)的窗口函數(shù)的地址
Public Const WM_CONTEXTMENU = &H7B ' 當(dāng)右擊文本框時(shí),產(chǎn)生這條消息
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd _
As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd _ As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private 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 Function SubClass_WndMessage(ByVal hWnd As Long, ByVal Msg As Long, ByVal wp _