Make the cursor invisible.

  • Thread starter Thread starter Silvio
  • Start date Start date
S

Silvio

Is there a way to make the cursor invisible when clicking into a text box?

Thank you,
Silvio
 
Silvio said:
Is there a way to make the cursor invisible when clicking into a text box?


Are you talking about the text caret, or about the mouse cursor? The text
caret can be hidden and shown using Windows API calls. For example:

'------ start of example code for a form's module ------
Option Compare Database
Option Explicit

Private Declare Function apiShowCaret Lib "user32" _
Alias "ShowCaret" _
(ByVal hWnd As Long) _
As Long

Private Declare Function apiHideCaret Lib "user32" _
Alias "HideCaret" _
(ByVal hWnd As Long) _
As Long

Private Declare Function apiGetFocus Lib "user32" _
Alias "GetFocus" _
() As Long


Private Sub Text1_GotFocus()

' Hide the text caret when text box Text1 has the focus.

Dim lngRet As Long

lngRet = apiHideCaret(apiGetFocus())

End Sub


Private Sub Text1_LostFocus()


' Show the text caret when text box Text1 loses the focus.

Dim lngRet As Long

lngRet = apiShowCaret(apiGetFocus())

End Sub
'------ end of example code for a form's module ------
 
Thanks Dirk for your time. I am talking about the mouse/keyboard cursor
(blinking vertical line) that you normally see when clicking into a text box.
I need to set focus on that specific text box by clicking in it, but I don’t'
want to see the blinking keyboard/mouse cursor in there.
 
Silvio said:
Thanks Dirk for your time. I am talking about the mouse/keyboard cursor
(blinking vertical line) that you normally see when clicking into a text
box.

That is the text caret. The code I posted, suitably adapted to your text
box, will take care of it.
 
Back
Top