Make the cursor invisible.

S

Silvio

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

Thank you,
Silvio
 
D

Dirk Goldgar

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 ------
 
S

Silvio

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.
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top