Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine when to use black or white as label forecolor
Message
De
13/06/2005 10:55:37
 
 
À
13/06/2005 10:20:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01022663
Message ID:
01022774
Vues:
21
This message has been marked as the solution to the initial question of the thread.
Found a solution thanks to Jim Kearns (FoxToolbox.com) and Shawn Dorian/Dan Covill on Ed Leafe's Profox list.
*-- The function "RGBComp" is contained in FoxTools.fll.  laBackColor is the
*-- user chosen background color.

llReturnValue = RGBComp(laBackColor, @lnRed, @lnGreen, @lnBlue)
      
*-- We're trying to obtain the ideal forecolor for the user specified
*-- backcolor.  Thanks to Shawn Dorion and Dan Covill on the ProFox list
*-- for the basis of this solution.
      
lnForeColor = RGB(255,255,255) && Default to White
      
IF (lnRed + lnGreen + lnBlue) > (128 + 128 + 128)
      
  lnForeColor = RGB(0,0,0)     && Black will be more readable here.
          
ENDIF
A tip for those reading this thread - if you need to find the background color on top of a gradient background where the gradient fade is gradual, you can use ThisForm.Point() method to determine the pixel color underneath or near a specific part of your transparent label.

Malcolm
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform