VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Custom technique for 'Search Cue-like' effect without any API Very easily create same effect as in

by Dipen Anovadia (19 Submissions)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 17th April 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Custom technique for 'Search Cue-like' effect without any API Very easily create same effect as in Windows XP

Rate Custom technique for 'Search Cue-like' effect without any API Very easily create same effect as in




'Custom technique for 'Search Cue-like' effect without any API
'Very easily create same effect as in Windows XP

'Form1
'   CommandButtons - 2  (Command1, Command2)
'   TextBoxes - 2       (Text1, Text2)

'   Text1   -   Testing the Cue-Effect here...
'   Text2   -   Custom Cue Text
'   Command1-   Enable effect    [Command1.Caption = "Enable"]
'   Command2-   Disable effect   [Command2.Caption = "Disable"]

'Just re-design codes to get it as per your
'requirement.

'Please contact in case of errors, feedbacks, etc...
'Email: [email protected]



Dim bInternalCall As Boolean
Dim bEnabled As Boolean

Dim CueColor As OLE_COLOR
Dim sCueText As String

Private Sub Command1_Click()

    If bEnabled Then Exit Sub

    bEnabled = True

    If Trim$(Text1) = "" Then Call Text1_LostFocus
End Sub

Private Sub Command2_Click()

    If Not bEnabled Then Exit Sub

    bEnabled = False

    If Text1 = Text2 Then
        bInternalCall = True
        Text1 = ""
    End If
End Sub

Private Sub Form_Load()

    bKeyChange = False
    bEnabled = False
    bLastState = False

    CueColor = vbGrayText

    Text1 = ""

    sCueText = "Enter your search text here!"
    Text2 = sCueText
End Sub

Private Sub Text1_Change()

    If bInternalCall Then
        bInternalCall = False
        Exit Sub
    End If

    If Not (Text1.ForeColor = vbButtonText) Then Text1.ForeColor = vbButtonText
End Sub

Private Sub Text1_GotFocus()

    If bEnabled Then
        If (Text1 = Text2) Or (Trim$(Text1) = "") Then
            bInternalCall = True
            Text1 = Empty
        Else
            SelTextBox Text1
        End If
    Else
        SelTextBox Text1
    End If
End Sub

Private Sub Text1_LostFocus()

    If bEnabled Then
        If Not (Text1 = "") And Not (Text1 = Text2) Then
            If Not (Text1.ForeColor = vbButtonText) Then Text1.ForeColor = vbButtonText

            Exit Sub
        End If

        If Not (Text1.ForeColor = CueColor) Then Text1.ForeColor = CueColor

        If Trim$(Text2) = "" Then Text2 = sCueText

        bInternalCall = True
        Text1 = Text2
    Else
        Text1.ForeColor = vbButtonText
    End If
End Sub

Private Sub Text2_GotFocus()

    SelTextBox Text2
End Sub

Public Sub SelTextBox(tb As TextBox)

    tb.SelStart = 0
    tb.SelLength = Len(tb)
End Sub


Download this snippet    Add to My Saved Code

Custom technique for 'Search Cue-like' effect without any API Very easily create same effect as in Comments

No comments have been posted about Custom technique for 'Search Cue-like' effect without any API Very easily create same effect as in . Why not be the first to post a comment about Custom technique for 'Search Cue-like' effect without any API Very easily create same effect as in .

Post your comment

Subject:
Message:
0/1000 characters