Changing the cursor in a textbox.

Hi,
how can i change the cursor that blinks in a textbox,
from a vertical one to horizontal - like dos?
but what i realy need is that the cursor will be like a small green sqaure that when
i move the cursor with the left or right key he will highlight the next letter in the textbox.
thanks...
KinGuyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ryan ChongConnect With a Mentor Commented:
Try use CreateCaret API:

Example:

'On form1 place 2 textboxes (with a height for a couple of lines) and 1 picturebox.
'Select a bitmap for the picturebox and set the autosize on true.
Private Declare Function CreateCaret Lib "user32" (ByVal hwnd As Long, ByVal hBitmap As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function ShowCaret Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetFocus Lib "user32" () As Long
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net

    'Execute the app. (F5) and you'll see the difference of the cursorshapes.
End Sub
Sub Text1_GotFocus()
    'retrieve the window which has the focus
    h& = GetFocus&()
    'retrieve the handle of our picture
    b& = Picture1.Picture
    'Create a new cursor
    '(handle, bitmap 0=none, width, height)
    Call CreateCaret(h&, b&, 10, 10)
    'Show our new cursor
    X& = ShowCaret&(h&)
End Sub
Private Sub Text2_GotFocus()
    'retrieve the window which has the focus
    h& = GetFocus&()
    'Create a new cursor
    Call CreateCaret(h&, 0, 30, 30)
    'Show the new cursor
    X& = ShowCaret&(h&)
End Sub
0
 
KinGuyAuthor Commented:
Thank you for your comment ryancys, but can i stop it from blinking?
Guy
0
 
Ryan ChongCommented:
>>but can i stop it from blinking
Try look for the SetCaretBlinkTime API ?

Example:

Private Declare Function SetCaretBlinkTime Lib "user32" (ByVal wMSeconds As Long) As Long
Private Declare Function GetCaretBlinkTime Lib "user32" () As Long
Dim nOldBT As Long
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@allapi.net
    'retrieve the current caret blinktime
    nOldBT = GetCaretBlinkTime
    'set the new caret blinktime
    SetCaretBlinkTime 1
    'When the form is loaded, open a text-editor and check out the caret blinktime
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'restore the old caret blinktime
    SetCaretBlinkTime nOldBT
End Sub
0
 
Ashutosh VyasFounder, InitQubeCommented:
Try using the SelStart and SelLength properties of the textbox.
This highlights the text in the textbox.
Use these on your keydown events.

KeyCode = 39 for UP
Keycode = 37 for DOWN
0
 
KinGuyAuthor Commented:
Hi, i know i weren't here for a long time but army is army and you can't do nothing about it.
thank you all guys but i need to make a carret like dos. that blinks and that is horizontal. and it needs to be in a textbox.
can i do that?

Thanks,
KinGuy
0
All Courses

From novice to tech pro — start learning today.