Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting integer color code into HTML color code
Message
From
26/07/2001 10:14:31
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00535531
Message ID:
00535663
Views:
12
Thanks Vlad

I think I'm doing something wrong.

I basically tried
lnColor=getcolor()
lcColor=strtran(transform(lnColor,'@0'),'0x','#')

This didn't seem to give me the correct color. For example, the color blue equals 8404992. The above gives me #00804000. That gives me this color. What am I doing wrong?

Thanks

David
>Hi!
>
>It is not needed to extract each color. strtran(transform(iColor,'@0'),'0x','#') is enough.
>
>>David,
>>
>>HTML color codes are stored RGB. In VFP the color code is stored RBG in the integer value returned by GetColor(). The easiest thoing to do is use RGBComp() to decompose the value:
>>
>>lnVFPColor = getcolor()
>>store 0 to lnRed, lnBlue, lnGreen
>>set library to foxtools additive
>>RGBComp( lnVFPColor, @lnRed, @lnGreen, @lnBlue )
>>
>>lcHTMLColor = "#" + right( transform( lnRed, "@0" ), 2 ) + right( transform( lnGreen, "@0" ), 2 ) + right( transform( lnBlue, "@0" ), 2 )
>>
>>>I need to convert an integer color code into an HTML color code.
>>>
>>>For example, if a user is prompted to select a color with getcolor(), and they choose red, the integer value returned is 255. In order to display the color red in HTML text, I need to either use 'font color="#FF0000"' or 'font color="red"'. How do I derive that "#FF0000" value from 255, or from any other valid color integer?
Previous
Reply
Map
View

Click here to load this message in the networking platform