• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1554
  • Last Modified:

Hide the cursor int the textBox.

I have many txtBoxes locked. I want to hide the cursor in the txtBox(not the mousePointer) and i want to unhide it when we write inside. Is it possible? is it complicated? If No how we do it?
Code would be appreciate.
  • 3
1 Solution
Private Declare Function HideCaret Lib "user32" (ByVal hWnd As Long) As Long
Private Sub Text1_GotFocus()
    Call HideCaret(Text1.hWnd)
End Sub
for showing a cursor
Public Declare Function ShowCaret Lib "user32" Alias "ShowCaret" (ByVal hwnd As Long) As Long

for hiding a cursor
Public Declare Function HideCaret Lib "user32" Alias "HideCaret" (ByVal hwnd As Long) As Long

ShowCaret Text1.hwnd ' show a cursor
HideCaret Text1.hwnd  'hide a curosr

Hope this helps you.
Nice 1 Ruchi!
I always use this 'trick':

I set a tag of a control to 1 or 0 if a text box may be edited.
Then in the Got_Focus event:

Private Sub Text1_GotFocus()
    If MyCheckControl.Tag = "0" Then MyControl.SetFocus
End Sub

So I redirect the focus to a control that MAY have the focus.

But, to be quite honest: I like Ruchi's idea better ! ;-))

dosylAuthor Commented:
Thank's a lot.
You are welcome, Dosyl.
Thanks, Roverm.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now