borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Checking one or more hdds  to see if a file exists)Next Topic (PictureBox Content Clear after Print) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Text Effect
Poster Message
VBBear
Level: Guest


icon Text Effect

'----------------------------------------------------------------------------------------------
' Text Effect
' Nghiem Phu Cuong
' www.diachiweb.com
'
' Create a new project, add new command button to form, ' copy code after that press F9 key
'----------------------------------------------------------------------------------------------

Private m_bDoEffect As Boolean

Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Function SetTextCharacterExtra Lib "gdi32" (ByVal hdc As Long, ByVal nCharExtra As Long) As Long
Private Type RECT
    left As Long
    tOp As Long
    Right As Long
    Bottom As Long
End Type
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private Const COLOR_BTNFACE = 15
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Const DT_BOTTOM = &H8
Private Const DT_CALCRECT = &H400
Private Const DT_CENTER = &H1
Private Const DT_CHARSTREAM = 4          '  Character-stream, PLP
Private Const DT_DISPFILE = 6            '  Display-file
Private Const DT_EXPANDTABS = &H40
Private Const DT_EXTERNALLEADING = &H200
Private Const DT_INTERNAL = &H1000
Private Const DT_LEFT = &H0
Private Const DT_METAFILE = 5            '  Metafile, VDM
Private Const DT_NOCLIP = &H100
Private Const DT_NOPREFIX = &H800
Private Const DT_PLOTTER = 0             '  Vector plotter
Private Const DT_RASCAMERA = 3           '  Raster camera
Private Const DT_RASDISPLAY = 1          '  Raster display
Private Const DT_RASPRINTER = 2          '  Raster printer
Private Const DT_RIGHT = &H2
Private Const DT_SINGLELINE = &H20
Private Const DT_TABSTOP = &H80
Private Const DT_TOP = &H0
Private Const DT_VCENTER = &H4
Private Const DT_WORDBREAK = &H10
Private Declare Function OleTranslateColor Lib "OLEPRO32.DLL" (ByVal OLE_COLOR As Long, ByVal HPALETTE As Long, pccolorref As Long) As Long
Private Const CLR_INVALID = -1
Private Sub TextEffect( _
        ByVal sText As String, _
        ByVal lX As Long, ByVal lY As Long, _
        Optional ByVal bLoop As Boolean = False, _
        Optional ByVal lStartSpacing As Long = 128, _
        Optional ByVal lEndSpacing As Long = -1, _
        Optional ByVal oColor As OLE_COLOR = vbWindowText _
        )
Dim i As Long
Dim x As Long
Dim lLen As Long
Dim lHDC As Long
Dim hBrush As Long
Static tR As RECT
Dim iDir As Long
Dim bNotFirstTime As Boolean
Dim lTime As Long
Dim lIter As Long
Dim bSlowDown As Boolean
Dim lCOlor As Long
Dim bDoIt As Boolean


    iDir = -1
    i = lStartSpacing
    tR.left = lX: tR.tOp = lY: tR.Right = lX: tR.Bottom = lY
    OleTranslateColor oColor, 0, lCOlor

    hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE))
    lLen = Len(sText)
    lHDC = Me.hdc
    SetTextColor lHDC, lCOlor
    bDoIt = True
  
    Do While m_bDoEffect And bDoIt
        lTime = timeGetTime
        If (i < -3) And Not (bLoop) And Not (bSlowDown) Then
            bSlowDown = True
            iDir = 1
            lIter = (i + 4)
        End If
        If (i > 128) Then iDir = -1
        If Not (bLoop) And iDir = 1 Then
            If (i = lEndSpacing) Then
                ' Stop
                bDoIt = False
            Else
                lIter = lIter - 1
                If (lIter <= 0) Then
                    i = i + iDir
                    lIter = (i + 4)
                End If
            End If
        Else
            i = i + iDir
        End If
        FillRect lHDC, tR, hBrush
        x = 32 - (i * lLen)
        SetTextCharacterExtra lHDC, i
        DrawText lHDC, sText, lLen, tR, DT_CALCRECT
        tR.Right = tR.Right + 4
        If (tR.Right > Me.ScaleWidth  Screen.TwipsPerPixelX) Then tR.Right = Me.ScaleWidth  Screen.TwipsPerPixelX
        DrawText lHDC, sText, lLen, tR, DT_LEFT
        Me.Refresh
        Do
            DoEvents
        Loop While (timeGetTime - lTime) < 20
    Loop
    DeleteObject hBrush

End Sub


Private Sub cmdOK_Click()
    Unload Me
End Sub


Private Sub Form_Load()
    Me.Show
    Me.Refresh
    If Not (m_bDoEffect) Then
        Me.Cls
        Me.Font.Size = 24
        m_bDoEffect = True
        TextEffect "Download IT ebooks", 12, 12, , 128, -2, RGB(&H80, 0, 0)
        If m_bDoEffect Then
            Me.Font.Size = 14
            TextEffect "www.diachiweb.com", 36, 52, , 128, , vb3DShadow
        End If
        If m_bDoEffect Then
            Me.Font.Name = "Tahoma"
            Me.Font.Size = 8
            Me.Font.Bold = False
            TextEffect "A lot of free IT ebooks", 49, 86, , 128, 0
        End If
        If m_bDoEffect Then
            TextEffect "Please, visit.", 49, 100, , 128, 0
        End If
        m_bDoEffect = False
    Else
        m_bDoEffect = False
    End If

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    m_bDoEffect = False
End Sub


[Edited by VBBear on 09-06-2004 at 06:17 AM GMT]

09-06-2004 at 06:16 AM
| Quote Reply
AndreaVB Forum : VB General : Text Effect
Previous Topic (Checking one or more hdds  to see if a file exists)Next Topic (PictureBox Content Clear after Print) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder