Changing Color of Get

Changing Color of Get

Postby Jack » Thu Dec 01, 2022 7:46 pm

Hi,
I have a dialog from a rc with 1 get with a numeric var and 1 multiline get .
I want to change the background color of the multiline field depending of the value entered in the firts numeric .

Any samples ?

Thanks

Philippe
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Changing Color of Get

Postby karinha » Thu Dec 01, 2022 8:08 pm

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

Re: Changing Color of Get

Postby nageswaragunupudi » Fri Dec 02, 2022 12:37 pm

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local aColors := { CLR_WHITE, CLR_YELLOW, CLR_HGREEN }
   local oDlg, oFont, oGet, oMemo, n
   local nColor   := 1
   local CText    := "This is some" + CRLF + "text"

   SetGetColorFocus()

   DEFINE DIALOG oDlg SIZE 300,350 PIXEL TRUEPIXEL

   @ 20,20 SAY "Color Code : " GET nColor SIZE 200,24 PIXEL PICTURE "9" ;
      OF oDlg VALID ( ;
            n  := aColors[ ( ( nColor - 1 ) % 3 ) + 1 ], ;
            oMemo:SetColor( CLR_BLACK, n ), ;
            .t. )

   @ 60,20 GET oMemo VAR cText MEMO SIZE 260,270 PIXEL OF oDlg ;
      COLORS CLR_BLACK, aColors[ nColor ]

   ACTIVATE DIALOG oDlg CENTERED ON INIT oMemo:SetFocus()

return nil
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Changing Color of Get

Postby karinha » Fri Dec 02, 2022 2:21 pm

Another way to change the color of the GET:

Code: Select all  Expand view

// C:\FWH..\SAMPLES\CORGET2.PRG

#include "fivewin.ch"

#Define CLR_SOFTYELLOW nRGB( 255, 251, 225 ) //-> Amerelo Soft.

FUNCTION Main()

   LOCAL aColors := { CLR_WHITE, CLR_YELLOW, CLR_HGREEN }
   LOCAL oDlg, oFont, oGet, oMemo, n, oBtnCal, oBtnCan
   LOCAL nColor   := 1
   LOCAL CText    := "This is some" + CRLF + "text"

   SetGetColorFocus()

   tGet():lDisColors  := .F.
   tGet():nClrTextDis := CLR_HBLUE
   tGet():nClrPaneDis := CLR_WHITE

   DEFINE FONT oFont  NAME "Ms Sans Serif"  SIZE 00, -18 BOLD

   DEFINE DIALOG oDlg SIZE 300,350 PIXEL TRUEPIXEL FONT oFont ;
      COLORS CLR_BLACK, CLR_WHITE TRANSPARENT

   oDlg:lHelpIcon := .F.

   /*
   @ 20,20 SAY "Color Code : " GET nColor SIZE 200,24 PIXEL PICTURE "9" ;
      OF oDlg VALID ( ;
            n  := aColors[ ( ( nColor - 1 ) % 3 ) + 1 ], ;
            oMemo:SetColor( CLR_BLACK, n ), ;
            .t. )
   */


   @ 20, 20 SAY "Cambiar Color: " SIZE 200,24 PIXEL OF oDlg UPDATE TRANSPARENT

   @ 60, 20 GET oMemo VAR cText MEMO SIZE 260,220 PIXEL OF oDlg  /* ;
      COLORS CLR_BLACK, aColors[ nColor ] */


   @ 300, 100  BTNBMP oBtnCal FILENAME "..\bitmaps\16x16\floppy.bmp" ;
       FLAT SIZE 20, 14 PIXEL OF oDlg NOBORDER                     ;
       ACTION SET_COLOR( oMemo, nColor )

   @ 300, 150  BTNBMP oBtnCan FILENAME "..\bitmaps\16x16\Exit.bmp" ;
       FLAT SIZE 20, 14 PIXEL OF oDlg NOBORDER                     ;
       ACTION( oDlg:End() )

   oBtnCan:lCancel := .T.

   ACTIVATE DIALOG oDlg CENTERED ON INIT oMemo:SetFocus()

   oFont:End()

RETURN NIL

FUNCTION SET_COLOR( oMemo, nColor )

   LOCAL oIni, oBrush, oBmp
   LOCAL nTipo, cStyle, cFile, cLogo, nRow, nCol, lSelect

   nColor := ChooseColor()

   oMemo:SetColor( nColor, CLR_WHITE )
   oMemo:Refresh()

RETURN( nColor )

// FIN / END
 


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

Re: Changing Color of Get

Postby Jack » Sat Dec 03, 2022 9:15 am

Thanks for this samples !

Philippe
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am

Re: Changing Color of Get

Postby Silvio.Falconi » Wed Dec 07, 2022 8:50 am

With the new BtnClr class from Next fwh package

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Changing Color of Get

Postby karinha » Wed Dec 07, 2022 12:50 pm

Silvio.Falconi wrote:With the new BtnClr class from Next fwh package

Image


Very good.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests