Refrescar Say en un Tpanel

Post Reply
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Refrescar Say en un Tpanel

Post by FranciscoA »

Eso, amigos.
Cual es la forma de refrescar un Tsay que está contenido en un TPanel (que contiene otros controles), en un dialogo de recursos?
Es decir, desde un xBrowse, al cambiar posicion , refrescar el say con el valor de x columna del browse.
Algo asi (ej tomado del foro y modificado:

Code: Select all

Function MyPanel()
   local oDlg, oPanel
   local oBrw, c1, oSay

   DBUSEAREA(.T.,,"STATES","STATES",.T.)

   DEFINE DIALOG oDlg SIZE 600,600 PIXEL 

   @ 140,20 XBROWSE oBrw OF oDlg PIXEL ; 
            SIZE 150, 150 ;
            AUTOCOLS ;
            DATASOURCE "STATES"

   oBrw:CreateFromCode()

   c1 := oBrw:aCols[2]:Value
   oBrw:bChange := {|| c1 := oBrw:aCols[2]:Value, oPanel:Refresh() }

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oPanel := CreatePanel( oDlg,@c1,oSay,.t. ) )

   STATES->(DBCLOSEAREA())
return nil

//--------------------------------------//
function CreatePanel( oDlg, c1, oSay )
   local oPanel
   local aGrad  := { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }
   //local c1    := "Hello World       "
   local c2    := Space( 100 )

   oPanel := TPanel():New( 050,050,250,550,oDlg )
   oPanel:Gradient( aGrad )
   oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }  //Con borde

   @ 40,20 SAY oSay VAR c1 SIZE 200,24 PIXEL OF oPanel
   @ 80,20 GET c2 SIZE 200,24 PIXEL OF oPanel

return oPanel
 
Gracias.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Refrescar Say en un Tpanel

Post by cnavarro »

Prueba asi

Code: Select all

oPanel:aControls[ 1 ]:Refresh()
 
o

Code: Select all

AEVal( oPanel:aControls, { | o | o:Refresh() } )
 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Refrescar Say en un Tpanel

Post by FranciscoA »

Cristobal, gracias por contestar.
Ya lo habia intentado de la primera forma.
No hubo ninguna diferencia. No se refresca el tpanel.
Algún otro modo?
Gracias.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Refrescar Say en un Tpanel

Post by FranciscoA »

Cristobal.
Parece que tu atencióm y el aire fresco de la mañana me dieron la luz, después de muuuuuchas horas.
Era colocar la variable c1 como estática en el prg principal. A veces nos ahogamos en un vaso de agua.

Code: Select all

STATIC c1    //esto era la solucion

//----------------------------------------------//
Function MyPanel()
   local oDlg, oPanel
   local oBrw

   DBUSEAREA(.T.,,"STATES","STATES",.T.)

   DEFINE DIALOG oDlg SIZE 600,600 PIXEL 

   @ 140,20 XBROWSE oBrw OF oDlg PIXEL ; 
            SIZE 150, 150 ;
            AUTOCOLS ;
            DATASOURCE "STATES"

   oBrw:CreateFromCode()

   c1 := oBrw:aCols[2]:Value
   oBrw:bChange := {|| c1 := oBrw:aCols[2]:Value, AEVal( oPanel:aControls, { | o | o:Refresh() } ) }


   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oPanel := CreatePanel( oDlg ) )

   STATES->(DBCLOSEAREA())
return nil

//--------------------------------------//
function CreatePanel( oDlg )
   local oPanel, oDlg
   local aGrad  := { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }
   //local c1    := "Hello World       "    //static
   local c2    := Space( 100 )

   oPanel := TPanel():New( 050,050,250,550,oDlg )
   oPanel:Gradient( aGrad )
   oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }  //Con borde

   @ 40,20 SAY oSay VAR c1 SIZE 200,24 PIXEL OF oPanel
   @ 80,20 GET c2 SIZE 200,24 PIXEL OF oPanel

return oPanel
 
Gracias.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh1204-MySql-TMySql
Post Reply