Option Explicit
Public bBlockMenu As Boolean
Public Const WM_USER = &H400
Public Const EM_HIDESELECTION = WM_USER + 63
Public Const WM_UNDO = &H304
Public Const EM_CANUNDO = &HC6
Public Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Long) As Long
Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Public Sub ReplaceMenu(ByRef objX As Object, _
mnuX As Object)
'lock the text box for my personal use
LockWindowUpdate objX.hwnd
'the text box MUST be disabled to
'prohibit default popup menu
objX.Enabled = False
'releases the lock
LockWindowUpdate 0&
DoEvents
objX.Enabled = True
objX.SetFocus
objX.Parent.PopupMenu mnuX
On Error GoTo DeletedItself:
objX.Enabled = True
DeletedItself:
End Sub
Public Sub EditUndo(ByRef objX As Object)
If CBool(SendMessage(objX.hwnd, EM_CANUNDO, 0, ByVal 0&)) Then
SendMessage objX.hwnd, WM_UNDO, 0, ByVal 0&
End If
End Sub
Public Sub EditCut(ByRef objX As Object)
' On Error GoTo NoSel:
' ' Clear the contents of the Clipboard.
' Clipboard.Clear
' ' Copy selected text to Clipboard.
' Clipboard.SetText objX.SelText
' ' Delete selected text.
' objX.SelText = ""
'NoSel:
objX.SetFocus
SendKeys "{BACKSPACE}" ' "^C"
End Sub
Public Sub EditCopy(ByRef objX As Object)
On Error GoTo NoSel:
' Clear the contents of the Clipboard.
Clipboard.Clear
' Copy selected text to Clipboard.
Clipboard.SetText objX.SelText
NoSel:
End Sub
Public Sub EditPaste(ByRef objX As Object)
' On Error GoTo NoSel:
' ' Place text from Clipboard into active control.
' objX.SelText = vbNullString
' objX.SelText = Clipboard.GetText()
'NoSel:
SendKeys "^v"
End Sub
Public Sub EditSelectAll(ByRef objX As Object)
On Error GoTo NoSel:
objX.SelStart = 0
objX.SelLength = Len(objX.Text)
NoSel:
End Sub
Public Sub EditCopyAll(ByRef objX As Object)
On Error GoTo NoSel:
' Clear the contents of the Clipboard.
Clipboard.Clear
' Copy all of the text
Clipboard.SetText objX.Text
NoSel:
End Sub
Public Sub EditDelete(ByRef objX As Object)
' On Error GoTo NoSel:
' objX.SelText = vbNullString
'NoSel:
objX.SetFocus
SendKeys "{DEL}"
End Sub