DEFINIR COLOR DEL BTNBMPBu

DEFINIR COLOR DEL BTNBMPBu

Postby Willi Quintana » Mon Nov 22, 2021 4:13 pm

Buenos dias amigos...
Como definiria el color de un BTNBMP de manera permanante en una app.

Encontré éste código en el foro, y me parece interesante, quisiera aplicarlo para todo los BTNBMP de la app con una sola definición.

Gracias.

//------------------------------
Function Color_oBot(oBot,cColor)
DEFAULT cColor := NIL
IF !cColor = NIL
if cColor = "ORO"
oBot:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
{ { 1.00,14481663,38075 }, ;
{ 1.00,38075,14481663 } }, ;
{ { 0.10,16777215,9363707 },;
{ 0.10,9363707,16777215 } } ) }
oBot:SetColor(0)

elseif cColor = "PLATA"
oBot:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
{ { 0.30,12961221,16777215 },;
{ 0.30,16777215,12961221 } },;
{ { 0.10,9363707,16777215 },;
{ 0.10,16777215,9363707 } } ) }
oBot:SetColor(0)
endif
ENDIF
Return nil
User avatar
Willi Quintana
 
Posts: 1002
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: DEFINIR COLOR DEL BTNBMPBu

Postby karinha » Mon Nov 22, 2021 5:11 pm

Code: Select all  Expand view

// \samples\CORBTN3.PRG - 22/11/2021

#include "FiveWin.Ch"

// --------------------------// BOTONES DE DIFERENTES COLORES O NO.
FUNCTION Main()   // ColorBtns()

   LOCAL oDlg, nButton, oFont, oBtn := Array( 5 ), cTitle, aGrad

   cTitle  := "BOTONES DE COLORES - COLORS IN BUTTONS - GLOBAL"

   SkinButtons()

   // aGrad := { { 0.30, CLR_BLACK, CLR_YELLOW},{ 0.50, CLR_YELLOW, CLR_BLACK } }
   aGrad := { { 0.30, CLR_CYAN, CLR_HCYAN },{ 0.70, CLR_HCYAN, CLR_CYAN } }

   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, - 14 BOLD

   DEFINE DIALOG oDlg FROM 5, 5 TO 10, 60 TITLE cTitle GRADIENT aGrad

   oDlg:lHelpIcon := .F.

   @ 3, 2    BTNBMP oBtn[ 1 ] SIZE 50, 14 ;
      FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT

   @ 3, 60  BTNBMP oBtn[ 2 ] SIZE 50, 14  ;
      FILENAME "..\bitmaps\16x16\printer.bmp" FLAT

   @ 3, 120 BTNBMP oBtn[ 3 ] SIZE 50, 14  ;
      FILENAME "..\bitmaps\16x16\prop.bmp" FLAT

   FOR nButton = 1 TO 3 // FONT .and. COLORS.

      SET FONT OF oBtn[ nButton ] TO oFont

      SET_Color_oBot( oBtn[ nButton ], "APUB" )

   NEXT

   ACTIVATE DIALOG oDlg CENTERED

   oFont:End()

RETURN NIL

FUNCTION SET_Color_oBot( oBot, cColor )

   DEFAULT cColor := NIL

   IF .NOT. cColor = NIL

      IF cColor = "ORO"

         oBot:bClrGrad = {| lMouseOver | If( ! lMouseOver, ;
            { { 1.00, 14481663, 38075 }, ;
            { 1.00, 38075, 14481663 } }, ;
            { { 0.10, 16777215, 9363707 }, ;
            { 0.10, 9363707, 16777215 } } ) }

         oBot:SetColor( 0 )

      ELSEIF cColor = "PLATA"

         oBot:bClrGrad = {| lMouseOver | If( ! lMouseOver, ;
            { { 0.30, 12961221, 16777215 }, ;
            { 0.30, 16777215, 12961221 } }, ;
            { { 0.10, 9363707, 16777215 }, ;
            { 0.10, 16777215, 9363707 } } ) }

         oBot:SetColor( 0 )

      ELSEIF cColor = "AZUL"

         oBot:bClrGrad := {| lInvert | If( ! lInvert, { { 0.50, 16776960, 16777215 }, ;
            { 0.50, 16777215, 16776960 } }, ;
            { { 0.50, 128, 16777215 }, ;
            { 0.50, 16777215, 128 } } ) }

         oBot:SetColor( 0 )

      ELSEIF cColor = "APUB"

         oBot:bClrGrad := {| lInvert | If( lInvert, ;
            { { 1 / 3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
            { 2 / 3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) }  ;
             }, ;
            { { 1 / 2, nRGB( 219, 230, 244 ), nRGB( 207 - 50, 221 - 25, 255 ) }, ;
            { 1 / 2, nRGB( 201 - 50, 217 - 25, 255 ), nRGB( 231, 242, 255 ) }  ;
            } ) }

         oBot:SetColor( 0 )

      ENDIF

   ENDIF

RETURN NIL

// fin / end
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests