Web development India freelance website designer developer India SEO

Description:'Create outlined text using 5 transparent labels then call this routine to: create outline text, change outline text
color, remove outlined around text, change outline text size, hide all text etc. (there are a lot more possibilities!)
A few examples:
Call OutlinedTranspLabels(Form1, True, True, vbBlack, vbWhite,, "This is outlined text !") 'to get text outlined
Call OutlinedTranspLabels(Form1, True, False, , , , CentrLbl.Caption) 'to remove outline around pre-existing text
Call OutlinedTranspLabels(Form1, False) 'to hide all text/labels

Assumes: Paste this entire code in a module then on a form and NOT IN AN ARRAY, place 5 individual Labels named:
CentrLbl, TopLftLbl, TopRtLbl, BtmLftLbl and BtmRtLbl.
CentrLbl will be your main label so set it up as needed with any of these 7 properties at design time or prior to calling this routine:
Alignment, Font size, FontName, FontBold, FontItalic, FontStrikethru or FontUnderline.
Stick the remaining 4 labels out of sight.

Side Effects: The outlined text will come out better if CentrLbl has its BorderStyle set to 0-None.
Also some fonts/size and colors will come out better then others so experiment with them and have fun :

Option Explicit


Public Sub OutlinedTranspLabels(ByVal frm As Form, ByVal LblVisble As Boolean, Optional Outline As Boolean, Optional OutlnColr As ColorConstants, Optional TxtColr As ColorConstants, Optional FntSize As Integer, Optional strCaption As String)
Dim CenterLbl As Label, TopLft As Label, TopRt As Label, BtmLft As Label, BtmRt As Label
Dim lblLeft As Long, lblTop As Long, lblWidth As Long, lblHeiht As Long
Set CenterLbl = frm.CentrLbl
Set TopLft = frm.TopLftLbl
Set TopRt = frm.TopRtLbl
Set BtmLft = frm.BtmLftLbl
Set BtmRt = frm.BtmRtLbl
'----------------
'next 5 lines are required also to remove flicker when updating caption inside labels.
TopLft.Visible = False
TopRt.Visible = False
BtmLft.Visible = False
BtmRt.Visible = False
CenterLbl.Visible = False
'---------------
If LblVisble = False Then Exit Sub
If FntSize = 0 Then FntSize = CenterLbl.FontSize

With CenterLbl
.AutoSize = True
.Visible = LblVisble
.Caption = strCaption
.ForeColor = TxtColr
.BackStyle = vbTransparent
.FontSize = FntSize
.ZOrder 0
End With

If Outline = False Then
TopLft.Caption = Empty
TopRt.Caption = Empty
BtmLft.Caption = Empty
BtmRt.Caption = Empty
Exit Sub
End If
lblLeft = CenterLbl.Left
lblTop = CenterLbl.Top
lblWidth = CenterLbl.Width
lblHeiht = CenterLbl.Height
'Add -> "/ Screen.TwipsPerPixelX" folowing each FntSize in the ".Move" lines below if your form's ScaleMode is set to
' Pixels instead of Twips

With TopLft
.AutoSize = False
.Move lblLeft - FntSize, lblTop - FntSize, lblWidth, lblHeiht
.Caption = strCaption
.Visible = LblVisble
.ForeColor = OutlnColr
.BackStyle = vbTransparent
.BorderStyle = 0
.FontName = CenterLbl.FontName
.FontBold = CenterLbl.FontBold
.FontItalic = CenterLbl.FontItalic
.FontStrikethru = CenterLbl.FontStrikethru
.FontUnderline = CenterLbl.FontUnderline
.FontSize = FntSize
End With

With TopRt
.AutoSize = False
.Move lblLeft + FntSize, lblTop - FntSize, lblWidth, lblHeiht
.Caption = strCaption
.Visible = LblVisble
.ForeColor = OutlnColr
.BackStyle = vbTransparent
.BorderStyle = 0
.FontName = CenterLbl.FontName
.FontBold = CenterLbl.FontBold
.FontItalic = CenterLbl.FontItalic
.FontStrikethru = CenterLbl.FontStrikethru
.FontUnderline = CenterLbl.FontUnderline
.FontSize = FntSize
End With

With BtmLft
.AutoSize = False
.Move lblLeft - FntSize, lblTop + FntSize, lblWidth, lblHeiht
.Caption = strCaption
.Visible = LblVisble
.ForeColor = OutlnColr
.BackStyle = vbTransparent
.BorderStyle = 0
.FontName = CenterLbl.FontName
.FontBold = CenterLbl.FontBold
.FontItalic = CenterLbl.FontItalic
.FontStrikethru = CenterLbl.FontStrikethru
.FontUnderline = CenterLbl.FontUnderline
.FontSize = FntSize
End With

With BtmRt
.AutoSize = False
.Move lblLeft + FntSize, lblTop + FntSize, lblWidth, lblHeiht
.Caption = strCaption
.Visible = LblVisble
.ForeColor = OutlnColr
.BackStyle = vbTransparent
.BorderStyle = 0
.FontName = CenterLbl.FontName
.FontBold = CenterLbl.FontBold
.FontItalic = CenterLbl.FontItalic
.FontStrikethru = CenterLbl.FontStrikethru
.FontUnderline = CenterLbl.FontUnderline
.FontSize = FntSize
End With
End Sub

If you would like to use an array of labels with this code, just modify the Sub with these 5 expressions instead. Then, on
your form, use Outlbl(0) as your main/center label.

Set CenterLbl = frm.Outlbl(0)
Set
TopLft = frm.Outlbl(1)
Set TopRt =
frm.Outlbl(2)
Set BtmLft =
frm.Outlbl(3)
Set BtmRt = frm.Outlbl(4)
Keep the Planet clean! If this
Outlined Text

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

India web developer web development India | India web development company India ecommerce web developer