PDA

Click to See Complete Forum and Search --> : Blinking Cursor.


Crypt
Sep 8th, 2000, 09:57 AM
Hiyas,

I was just wondering if anyone could tell me how to set the position of the blinking cursor? u know the one that is constantly blinking when its in a text box, because I am modifinying contents on a text box of another window, but it makes the blinking cursor go to the start of the text box, and I want the user to be able to keep typing sort of thing. anyone know how to do this on another window?

thanx for any help.

Mad Compie
Sep 8th, 2000, 03:12 PM
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()
'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

Mad Compie
Sep 11th, 2000, 02:00 PM
Yet another extract from the KPD QPI guide, which really explains that you also have to use ShowCaret():


'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