[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Changing the cursor in a textbox.

Posted on 2004-10-25
7
Medium Priority
?
457 Views
Last Modified: 2013-12-26
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...
0
Comment
Question by:KinGuy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 400 total points
ID: 12406989
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
 

Author Comment

by:KinGuy
ID: 12415239
Thank you for your comment ryancys, but can i stop it from blinking?
Guy
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12417641
>>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
 
LVL 8

Expert Comment

by:Ashutosh Vyas
ID: 12419526
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
 

Author Comment

by:KinGuy
ID: 12709874
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question