Option Explicit
Private WithEvents TxtBoxInst As MSForms.TextBox
Private Declare Function HideCaret Lib "User32" _
(ByVal hWnd As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" ( _
pDest As Any, pSrc As Any, _
ByVal ByteLen As Long)
Private oTempObj As Object
'**************************************************
'\Public Property.
Public Property Let GetTextBoxPtr(ByVal Ptr As Long)
CopyMemory oTempObj, Ptr, 4
HideCaretAndLock oTempObj
Set TxtBoxInst = oTempObj
End Property
'***************************************************
'**************************************************
'Private Routines.
Private Sub Class_Terminate()
CopyMemory oTempObj, 0&, 4
End Sub
Private Sub TxtBoxInst_DblClick _
(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True
End Sub
Private Sub TxtBoxInst_KeyPress _
(ByVal KeyAscii As MSForms.ReturnInteger)
HideCaretAndLock TxtBoxInst
End Sub
Private Sub TxtBoxInst_MouseDown _
(ByVal Button As Integer, ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
HideCaretAndLock TxtBoxInst
End Sub
Private Sub HideCaretAndLock(TextBox As Object)
TextBox.TabStop = False
TextBox.Locked = True
DoEvents
HideCaret 0
End Sub
'******************************************************