Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LABEL color class
Message
 
To
18/10/2004 10:31:05
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00951785
Message ID:
00952608
Views:
8
Thanks Herman, how do I apply this code? I am familiar with non visual forms, but not classes.

>>I know vfp does not enable to mix colors of chars within a label like you see in EBAY's logo but has anyone come up with a class to do so?
>
>Hi Timothy,
>
>Try this. Put these class into a VCX file named "ClsLabel.VCX". Otherwise you can't change the caption and font style. Drop the "ColorLabel" class into the form.
>
>**************************************************
>*-- Class:        colorlabel ( clslabel.vcx )
>*-- ParentClass:  container
>*-- BaseClass:    container
>*
>DEFINE CLASS colorlabel AS container
>   Width = 55
>   Height = 24
>   BackStyle = 0
>   Name = "colorlabel"
>
>   **---  Additional properties
>   caption = "Color Label"
>   fontname = ""    && Blank/Empty = use FontName from FORM
>   fontsize = .F.   && FALSE = use FontSize from FORM
>   fontbold = .F.
>
>   ***
>   *** Add more FontStyle
>   ***
>
>
>   PROCEDURE Init
>      Local ln_X, lc_Object, ln_Left
>
>      With This
>         .BorderWidth = 0
>         If empty( .FontName )
>            .FontName = ThisForm.FontName
>         endif
>
>         If empty( .FontSize )
>            .FontSize = ThisForm.FontSize
>         endif
>
>         ln_left = 1
>         For ln_X = 1 to len( .Caption )
>            lc_Object = 'lblColor' + alltrim(str( ln_X ))
>            .NewObject( lc_Object, 'lblChar', 'ClsLabel', , ;
>                substr(.Caption, ln_X, 1), .FontName, .FontSize, .FontBold )
>
>            With .&lc_Object
>               .Top = 1
>               .Left = ln_Left
>               .Visible = .T.
>               ln_Left = ln_Left + .Width - 2
>            EndWith
>         Next
>
>         .Width = ln_Left + 2
>         .Height = .&lc_Object..Height + 1
>      EndWith
>   ENDPROC
>
>ENDDEFINE
>
>
>
>**************************************************
>*-- Class:        lblchar ( clslabel.vcx )
>*-- ParentClass:  label
>*-- BaseClass:    label
>*
>DEFINE CLASS lblchar AS label
>   AutoSize = .T.
>   BackStyle = 0
>   Caption = ""
>   Height = 17
>   Width = 2
>   Name = "lblchar"
>
>
>   PROCEDURE Init
>   LParameters tc_Char, tc_FontName, tn_FontSize, tl_FontBold
>
>      With This
>         .Caption = tc_Char
>         .FontName = tc_FontName
>         .FontSize = tn_FontSize
>         .FontBold = tl_FontBold
>         .ForeColor = int( round(rand(), 4) * 0xFFFFFF )
>      EndWith
>   ENDPROC
>
>ENDDEFINE
>
>
>HTH
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform