Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB4,VB5,VB6
Expertise: Intermediate
Jan 10, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Print3D - Display text with 3D effect

' Display a text with 3D effect
' OBJ can be a form or a PictureBox
' TEXT is the text to be displayed
' X, Y are the coordinate (in twips or in current coordinate system)
' SHADOWCOLOR is the color of the shadow (default is black)
' SHADOWOFFSET is the distance of shadow in pixels (default is 1 pixel)
'    can be negative to give different effect
'    Me.FontName = "Arial Black"
'    Me.FontSize = 20
'    Me.ForeColor = vbWhite
'    Print3D Me, "Test this", 20, 20, vbBlack, 1

Sub Print3D(ByVal obj As Object, ByVal Text As String, ByVal X As Long, _
    ByVal Y As Long, Optional ByVal shadowColor As Long = vbBlack, _
    Optional ByVal shadowOffset As Integer = 1)
    Dim saveColor As Long
    Dim offset As Single
    ' convert the offset into current coordinate system
    offset = Me.ScaleY(shadowOffset, vbPixels, obj.ScaleMode)
    ' Save current forecolor
    saveColor = obj.ForeColor
    ' Display the shadow first
    obj.CurrentX = X + offset
    obj.CurrentY = Y + offset
    obj.ForeColor = shadowColor
    obj.Print Text;
    ' Next display the text in current forecolor
    obj.ForeColor = saveColor
    obj.CurrentX = X - offset
    obj.CurrentY = Y - offset
    obj.Print Text;

End Sub

Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date