Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: beginner
Dec 4, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Change the blink rate of the caret

You can retrieve and change the blink rate of the flashing caret inside TextBox controls through a couple of simple API functions:

Private Declare Function SetCaretBlinkTime Lib "user32" (ByVal wMSeconds As _
    Long) As Long
Private Declare Function GetCaretBlinkTime Lib "user32" () As Long
For example you can double the current blink rate using this code

Dim saveBlinkTime As Long
saveBlinkTime = GetCaretBlinkTime()
SetCaretBlinkTime saveBlinkTime * 2
Remember that the blink time is a system-wide setting, so you should revert it to its original value when whenever you switch to another application (which requires subclassing techniques, however) or at least when the current form unloads:

Private Sub Form_Unload(Cancel As Integer)
    ' reset blink time before exiting
    SetCaretBlinkTime saveBlinkTime
End Sub
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date