| 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 |
India web developer web development India | India web development company India ecommerce web developer