Results 1 to 4 of 4

Thread: [RESOLVED] How To Change Caret (Insertion) Cursor?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    44

    Resolved [RESOLVED] How To Change Caret (Insertion) Cursor?

    Hi. I know this must be simple, but I've spent a few hours searching, reading and experimenting with no joy. So, can one of you please point me in the right direction.

    I have a form with multiple text boxes. When the form loads, I wan't the insertion point, (or caret), to be a "solid block."

    I have most of it working. The form loads properly, and the insertion point will go to the next, or first available free text box. So, I'm good to go on that part of the code. However, I'm stuck with how to get the insertion point, ( or caret), to show up as a block.

    So, if someone could help me with how to change the insertion point caret to be a block I would REALLY appreciate it.

    Thank you in advance for any suggestions.

    bjmarler

  2. #2
    Frenzied Member numtel's Avatar
    Join Date
    Apr 2000
    Location
    CA
    Posts
    1,163

    Re: How To Change Caret (Insertion) Cursor?

    VB Code:
    1. Private Declare Function CreateCaret Lib "user32" (ByVal hwnd As Long, ByVal hBitmap As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    2. Private Declare Function ShowCaret Lib "user32" (ByVal hwnd As Long) As Long
    3. Private Declare Function DestroyCaret Lib "user32" () As Long
    4.  
    5. Private Sub Text1_GotFocus()
    6.     DestroyCaret
    7.     CreateCaret Text1.hwnd, 0, 8, 14
    8.     ShowCaret Text1.hwnd
    9.  End Sub
    10.  
    11. Private Sub Text1_LostFocus()
    12.     DestroyCaret
    13. End Sub
    You may have to do some more code to activate the caret change like when the form loses the focus and then gets it back, the gotfocus isn't called right.

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How To Change Caret (Insertion) Cursor?

    Do you mean you just want something like this:
    VB Code:
    1. Private Sub Text1_GotFocus()
    2.     Text1.SelStart = 0 'this may need to be 1 (can't remember)
    3.     Text1.SelLength = Len(Text1.Text)
    4. End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    44

    Re: How To Change Caret (Insertion) Cursor?

    Thanks numtel, that is EXACTLY what I was wanting to do. Perfect. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width