FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Colorear un GET
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Colorear un GET
Posted: Mon Apr 14, 2014 03:28 AM

Amigos del foro:

Alguien sabe c贸mo colorear un GET multilinea (MEMO) al momento de tomar y perder el foco??,
lo tengo pero para un GET sin MEMO peo esto no funciona cuando es tipo MEMO.

Quiero que cuando el control tome el foco sea de un color el fondo con objeto de llamar la atenci贸n
del usuario.

Uso xHarbour y FWH 0810

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 02:57 PM
Mira se 茅s esto:

Code (fw): Select all Collapse
***************************************************
* Multi SAY/GET testing in 32 bit Xbase++ mode....*
* Jon Berg 10-8-99                                *
***************************************************
#include "FiveWin.ch"
*********************

static oWnd

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 30, 70 ;
      TITLE "Testing Says/Gets and Get Pictures and Foreground/Background Colors" ;
      MENU BuildMenu()

   SET MESSAGE OF oWnd TO "FiveWin++"

   ACTIVATE WINDOW oWnd MAXIMIZED

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "&Say/Get Testing"
      MENU
         MENUITEM "&Build Multi GET Dialog1 with PICTs "  ACTION (BldDlg1())
         MENUITEM "Item &2"  ACTION MsgInfo("Test Menu Item2")
         MENUITEM "Item &3"  ACTION MsgInfo("Test Menu Item3")
         SEPARATOR
         MENUITEM "Exit" ACTION oWnd:End()
      ENDMENU
  ENDMENU
return oMenu

//----------------------------------------------------------------------------//

function BldDlg1()

   local oDlg, oArial, oFont, oMemo
   local cName1    := "ONE          "
   local cName2    := "two        "
   local cName3    := "3        "
   local cName4    := "4       "
   local cName5    := "5        "
   local cName6    := "54321        "
   local cName7    := "567890                  "
   local lRESERVE  := .F.
   local cPROV_TYPE:= SPACE(20)
   local cPHONE    := SPACE(18)
   local dCERT_DATE:= CTOD('  /  /  ')
   local nPROC_DAYS:= 9876
   local cTEXT     := "Use Tab or Shift Tab to move to next get."+SPACE(256)
   LOCAL aGet      := ARRAY(5)

   SET EPOCH TO 1920
   SET CENTURY ON

   DEFINE DIALOG oDlg FROM 1, 1 TO 600, 800 ;
          TITLE "Hello Gets!"               ;
          STYLE  nOr(WS_POPUP,              ;
                     WS_VISIBLE,            ;
                     WS_CAPTION,            ;
                     WS_THICKFRAME,         ;
                     WS_SYSMENU,            ;
                     WS_MINIMIZEBOX,        ;
                     WS_MAXIMIZEBOX)        ;
          PIXEL OF oWnd                            && Defined by Pixels


   DEFINE FONT oFont NAME "FIXEDSYS" SIZE 10, -10    && Use a Nonproportional font
   SET FONT OF oDlg TO oFont                         && so characters line up in Says

   @  00, 03 SAY "Showing how to do SAY/GETs from source code.  No DLLs or RC files. " OF oDlg COLORS CLR_BLACK,CLR_YELLOW BORDER SIZE 300,10
   @  01, 03 SAY "Navigation Keys to traverse gets are Ret, Arrows, Tab and Shift Tab....ESC to close this Dialog" OF oDlg COLORS CLR_WHITE,CLR_BLUE   BORDER SIZE 380,10
   @  02, 03 SAY "Testing Say with different colors and a border. "  OF oDlg COLORS CLR_HRED   ,CLR_WHITE  BORDER SIZE 200,10
   @  03, 03 SAY "Testing Say with different colors and no border."  OF oDlg COLORS CLR_HBLUE  ,CLR_WHITE         SIZE 200,10
   @  05, 19 SAY "Field length" OF oDlg SIZE 65,10  && Use normal colors
   @  06, 19 SAY "      |     " OF oDlg SIZE 65,10

   @  07, 03 SAY "1  Chr No PICT                       13" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  08, 03 SAY "2  Chr No PICT                       11" OF oDlg COLORS CLR_BLUE  ,CLR_HCYAN BORDER SIZE 195,10
   @  09, 03 SAY "3  Chr No PICT                        9" OF oDlg COLORS CLR_RED   ,CLR_HCYAN BORDER SIZE 195,10
   @  10, 03 SAY "4  Chr    PICT 'NNNNNNNN'             8" OF oDlg COLORS CLR_HRED  ,CLR_HCYAN BORDER SIZE 195,10
   @  11, 03 SAY "5  Chr    PICT 'AAAAAAAAA'            9" OF oDlg COLORS CLR_HGREEN,CLR_HCYAN BORDER SIZE 195,10
   @  12, 03 SAY "6  Chr    PICT '9999999999'          13" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  13, 03 SAY "7  Chr    PICT '@K@!@S10'            24" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  14, 03 SAY "   Logic 'T/F or Y/N'                 1" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  15, 03 SAY "   Chr    PICT '@S5'and !EMPTY()     20" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  16, 03 SAY "   Chr    PICT '(999)A99-9!99-9999'  18" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  17, 03 SAY "   Date   !> comp date or empty       8" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  16.8,   35 SAY "Set Century is on."                  OF oDlg SIZE 195,10
   @  17.3,   35 SAY "Set Epoch is set to 1919."           OF oDlg SIZE 195,10
   @  18, 03 SAY "   Num    PICT '99' !>10             10" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  19, 03 SAY "   Memo No PICT                     256" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10

   @  07, 28 GET cName1     OF oDlg COLORS "B/BG" SIZE 20,10
   @  08, 28 GET cName2     OF oDlg COLORS CLR_BLACK,CLR_HCYAN
   @  09, 28 GET cName3     OF oDlg COLORS CLR_BLACK,CLR_YELLOW
   @  10, 28 GET cName4     OF oDlg PICTURE "NNNNNNNN"
   @  11, 28 GET cName5     OF oDlg PICTURE "AAAAAAAAA"
   @  12, 28 GET cName6     OF oDlg PICTURE "9999999999"

   @  13, 28 GET cName7     OF oDlg PICTURE "@K@!@S10"
   @  14, 28 GET lRESERVE   OF oDlg PICTURE  "Y"  MESSAGE "Please type in a Y or N "
   @  15, 28 GET cPROV_TYPE OF oDlg PICTURE  "@S5" VALID IF(EMPTY(cPROV_TYPE),(MSGINFO("You have to enter at least 1 Character"),.F.),.T.)
   @  16, 28 GET cPHONE     OF oDlg PICTURE  "(999)A99-9!99-9999"

   @  17, 28 GET dCERT_DATE OF oDlg SIZE 50,10 VALID (IF(dCERT_DATE>DATE(),(MSGINFO("Certification Date must not be greater than Computer Date or blank!"),.F.),.T.)) MESSAGE "Please type in the Certification Date"

   @  18, 28 GET nPROC_DAYS OF oDlg PICTURE "99" VALID (IF(nPROC_DAYS>10,(MSGINFO("Processing Days Must be less that 11 or Empty"),.F.),.T.)) MESSAGE "Please type in the Number of days it took to process"

   //@  19, 28 GET cText MEMO  OF oDlg SIZE 140,46
   @  19, 28 GET aGet[1] VAR cText MEMO  OF oDlg SIZE 140,46

   aGet[1]:SetColor( CLR_GREEN, CLR_BLACK ) // color en memo

   ACTIVATE DIALOG oDlg CENTERED ;
      ON LEFT CLICK nMsgBox( "Incredible!" )
   
return nil


salu2
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 03:50 PM
Karinha:

aGet[1]:SetColor( CLR_GREEN, CLR_BLACK ) // color en memo

Pretendo cambiar el color solo cuando el GET tome el foco y cuando pierda el foco volver
al color anterior

Saludos y muito obrigado
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 03:53 PM

Intenta con el ON CHANGE().

salu2

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 03:58 PM
karinha:

Nada del siguiente c贸digo funciona
Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 REDEFINE GET aGets[17] VAR oHdr:FAL ID 301 OF oDlg UPDATE;
聽 聽 聽 聽 聽 聽 聽 聽 MEMO;
聽 聽 聽 聽 聽 聽 聽 聽 ON CHANGE SetColor(RGB(0,0,0),RGB(197,205,255));
聽 聽 聽 聽 聽 聽 聽 聽 MESSAGE "Falla que reporta el cliente"

聽 聽 聽 聽 聽 聽 聽 聽aGets[17]:bGotFocus 聽:= {||SetColor(RGB(0,0,0),RGB(197,205,255))}
聽 聽聽聽 聽 聽 聽 aGets[17]:bLostFocus := {||SetColor(RGB(0,0,0),RGB(255,255,255))}


Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 05:41 PM
Intenta con este ejemplo, mira se comprende:

Code (fw): Select all Collapse
***************************************************
* Multi SAY/GET testing in 32 bit Xbase++ mode....*
* Jon Berg 10-8-99                                *
***************************************************
#include "FiveWin.ch"
*********************

static oWnd, lCambiaColor := .T.

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 30, 70 ;
      TITLE "Testing Says/Gets and Get Pictures and Foreground/Background Colors" ;
      MENU BuildMenu()

   SET MESSAGE OF oWnd TO "FiveWin++"

   ACTIVATE WINDOW oWnd MAXIMIZED

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "&Say/Get Testing"
      MENU
         MENUITEM "&Build Multi GET Dialog1 with PICTs "  ACTION (BldDlg1())
         MENUITEM "Item &2"  ACTION MsgInfo("Test Menu Item2")
         MENUITEM "Item &3"  ACTION MsgInfo("Test Menu Item3")
         SEPARATOR
         MENUITEM "Exit" ACTION oWnd:End()
      ENDMENU
  ENDMENU
return oMenu

//----------------------------------------------------------------------------//

function BldDlg1()

   local oDlg, oArial, oFont, oMemo
   local cName1    := "ONE          "
   local cName2    := "two        "
   local cName3    := "3        "
   local cName4    := "4       "
   local cName5    := "5        "
   local cName6    := "54321        "
   local cName7    := "567890                  "
   local lRESERVE  := .F.
   local cPROV_TYPE:= SPACE(20)
   local cPHONE    := SPACE(18)
   local dCERT_DATE:= CTOD('  /  /  ')
   local nPROC_DAYS:= 9876
   local cTEXT     := "Use Tab or Shift Tab to move to next get."+SPACE(256)
   LOCAL aGet      := ARRAY(5)

   SET EPOCH TO 1920
   SET CENTURY ON

   DEFINE DIALOG oDlg FROM 1, 1 TO 600, 800 ;
          TITLE "Hello Gets!"               ;
          STYLE  nOr(WS_POPUP,              ;
                     WS_VISIBLE,            ;
                     WS_CAPTION,            ;
                     WS_THICKFRAME,         ;
                     WS_SYSMENU,            ;
                     WS_MINIMIZEBOX,        ;
                     WS_MAXIMIZEBOX)        ;
          PIXEL OF oWnd                            && Defined by Pixels


   DEFINE FONT oFont NAME "FIXEDSYS" SIZE 10, -10    && Use a Nonproportional font
   SET FONT OF oDlg TO oFont                         && so characters line up in Says

   @  00, 03 SAY "Showing how to do SAY/GETs from source code.  No DLLs or RC files. " OF oDlg COLORS CLR_BLACK,CLR_YELLOW BORDER SIZE 300,10
   @  01, 03 SAY "Navigation Keys to traverse gets are Ret, Arrows, Tab and Shift Tab....ESC to close this Dialog" OF oDlg COLORS CLR_WHITE,CLR_BLUE   BORDER SIZE 380,10
   @  02, 03 SAY "Testing Say with different colors and a border. "  OF oDlg COLORS CLR_HRED   ,CLR_WHITE  BORDER SIZE 200,10
   @  03, 03 SAY "Testing Say with different colors and no border."  OF oDlg COLORS CLR_HBLUE  ,CLR_WHITE         SIZE 200,10
   @  05, 19 SAY "Field length" OF oDlg SIZE 65,10  && Use normal colors
   @  06, 19 SAY "      |     " OF oDlg SIZE 65,10

   @  07, 03 SAY "1  Chr No PICT                       13" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  08, 03 SAY "2  Chr No PICT                       11" OF oDlg COLORS CLR_BLUE  ,CLR_HCYAN BORDER SIZE 195,10
   @  09, 03 SAY "3  Chr No PICT                        9" OF oDlg COLORS CLR_RED   ,CLR_HCYAN BORDER SIZE 195,10
   @  10, 03 SAY "4  Chr    PICT 'NNNNNNNN'             8" OF oDlg COLORS CLR_HRED  ,CLR_HCYAN BORDER SIZE 195,10
   @  11, 03 SAY "5  Chr    PICT 'AAAAAAAAA'            9" OF oDlg COLORS CLR_HGREEN,CLR_HCYAN BORDER SIZE 195,10
   @  12, 03 SAY "6  Chr    PICT '9999999999'          13" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  13, 03 SAY "7  Chr    PICT '@K@!@S10'            24" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  14, 03 SAY "   Logic 'T/F or Y/N'                 1" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  15, 03 SAY "   Chr    PICT '@S5'and !EMPTY()     20" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  16, 03 SAY "   Chr    PICT '(999)A99-9!99-9999'  18" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  17, 03 SAY "   Date   !> comp date or empty       8" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  16.8,   35 SAY "Set Century is on."                  OF oDlg SIZE 195,10
   @  17.3,   35 SAY "Set Epoch is set to 1919."           OF oDlg SIZE 195,10
   @  18, 03 SAY "   Num    PICT '99' !>10             10" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10
   @  19, 03 SAY "   Memo No PICT                     256" OF oDlg COLORS CLR_BLACK ,CLR_HCYAN BORDER SIZE 195,10

   @  07, 28 GET cName1     OF oDlg COLORS "B/BG" SIZE 20,10
   @  08, 28 GET cName2     OF oDlg COLORS CLR_BLACK,CLR_HCYAN
   @  09, 28 GET cName3     OF oDlg COLORS CLR_BLACK,CLR_YELLOW
   @  10, 28 GET cName4     OF oDlg PICTURE "NNNNNNNN"
   @  11, 28 GET cName5     OF oDlg PICTURE "AAAAAAAAA"
   @  12, 28 GET cName6     OF oDlg PICTURE "9999999999"

   @  13, 28 GET cName7     OF oDlg PICTURE "@K@!@S10"
   @  14, 28 GET lRESERVE   OF oDlg PICTURE  "Y"  MESSAGE "Please type in a Y or N "
   @  15, 28 GET cPROV_TYPE OF oDlg PICTURE  "@S5" VALID IF(EMPTY(cPROV_TYPE),(MSGINFO("You have to enter at least 1 Character"),.F.),.T.)
   @  16, 28 GET cPHONE     OF oDlg PICTURE  "(999)A99-9!99-9999"

   @  17, 28 GET dCERT_DATE OF oDlg SIZE 50,10 VALID (IF(dCERT_DATE>DATE(),(MSGINFO("Certification Date must not be greater than Computer Date or blank!"),.F.),.T.)) MESSAGE "Please type in the Certification Date"

   @  18, 28 GET nPROC_DAYS OF oDlg PICTURE "99" VALID (IF(nPROC_DAYS>10,(MSGINFO("Processing Days Must be less that 11 or Empty"),.F.),.T.)) MESSAGE "Please type in the Number of days it took to process"

   //@  19, 28 GET cText MEMO  OF oDlg SIZE 140,46
   @  19, 28 GET aGet[1] VAR cText MEMO  OF oDlg SIZE 140,46 ;
             ON CHANGE( SET_COLOR( aGet ) )

    aGet[1]:SetColor( CLR_GREEN, CLR_BLACK ) // color en memo Inicial

   ACTIVATE DIALOG oDlg CENTERED ;
      ON LEFT CLICK nMsgBox( "Incredible!" )

   lCambiaColor := .T.
   
return nil

FUNCTION SET_COLOR( aGet )  // mas o menos esto, cambia a tu gosto.


  IF lCambiaColor // cambia color solo una viez

      aGet[1]:SetColor( aGet[1]:nClrText, nCor := ChooseColor( aGet[1]:nClrPane ) )

      aGet[1]:Refresh()
      aGet[1]:SetFocus()

   ENDIF

   lCambiaColor := .F.

RETURN NIL


Saludos.
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 10:25 PM
Armando, asi si funciona
Parecido a lo que te dice Karinha
Code (fw): Select all Collapse
    @ 10,1 get oGet1 VAR cVar1 MEMO SIZE 250,100 OF hWnd

    oGet1:bGotFocus  := {|o| o:SetColor(RGB(0,0,0),RGB(197,205,255)), o:Refresh() }
    oGet1:bLostFocus := {|o| o:SetColor(RGB(0,0,0),RGB(255,255,255)), o:Refresh() }
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Colorear un GET
Posted: Mon Apr 14, 2014 10:32 PM
Karinha, Cristobal y amigos:

Tomando sus ideas, finalmente qued贸 as铆
Code (fw): Select all Collapse
aGets[17]:bGotFocus 聽:= {|| aGets[17]:SetColor(RGB(0,0,0),RGB(197,205,255)),aGets[17]:Refresh()}
aGets[17]:bLostFocus := {|| aGets[17]:SetColor(RGB(0,0,0),RGB(255,255,255)),aGets[17]:Refresh()}

Crist贸bal, por supuesto que tambi茅n con tu ejemplo funciona de 100, saludos

Muito obrigado, Gracias
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero

Continue the discussion