Results 1 to 5 of 5

Thread: Every textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192

    Post

    I like to see in every txtbox a big cursor, therefore I use this in every txtbox_gotfocus:

    "h& = GetFocus&(): sb& = Picture1.Picture: Call CreateCaret(h&, sb&, 1, 5): sx& = ShowCaret&(h&)"

    Can I get this by just type this once in the form ?

    Regards, K. Lensen

    ------------------

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124

    Post

    Put your code in a function and pass the textbox as an argument. Like this
    Code:
    Private Function fnLargeCursor(ByRef MyTextBox as TextBox)
        'Place your code here using MyTextBox as the text box name
    End Function
    In the GotFocus Event call the function:
    Code:
    Private Sub Text1_GotFocus
        call fnLargeCursor(Text1)
    End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192

    Post

    Originally posted by bsmith:
    Put your code in a function and pass the textbox as an argument. Like this
    Code:
    Private Function fnLargeCursor(ByRef MyTextBox as TextBox)
        'Place your code here using MyTextBox as the text box name
    End Function
    In the GotFocus Event call the function:
    Code:
    Private Sub Text1_GotFocus
        call fnLargeCursor(Text1)
    End Sub
    Yes, I now this works, but I have seen something like:
    For Each blabla in forms .... etc

    Can I use this and how ?


  4. #4
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124

    Post

    Is this code more of what you are looking for?
    Code:
    Private Sub Command1_Click()
    
        ' This code will loop through all controls on your form.
        ' It will only process the textboxes.
        Dim Thing As Variant
        
        For Each Thing In Form1
            If TypeOf Thing Is TextBox Then
                If Thing.Text = "" Then
                    ' Do what you need to do
                End If
            End If
        Next Thing
    
    End Sub

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    You can't. This is what MSDN has to say:


    The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active. The window should destroy the caret before losing the keyboard focus or becoming inactive.

    ShowCaret shows the caret only if the specified window owns the caret, the caret has a shape, and the caret has not been hidden two or more times in a row. If one or more of these conditions is not met, ShowCaret does nothing and returns FALSE.




    ------------------

    Serge

    Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819


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