Page 1 of 2

Nueva Clase TMeterEx

Posted: Wed Mar 24, 2010 7:32 pm
by Daniel Garcia-Gil
Nueva clase para FiveWin, nuevo estilo para la clase TMeter

Image

http://www.sitasoft.net/fivewin/samples/meterex.rar

Code: Select all

#include "FiveWin.ch"

function Main()

   LOCAL oWnd, nActual, nActual2, nActual3, nActual4
   LOCAL oMeter, oMeter2, oMeter3, oMeter4

   DEFINE WINDOW oWnd

   nActual := nActual2 := nActual3 := nActual4 := 0
   
   //   meter 1
   @ 10, 50 METEREX oMeter VAR nActual SIZE 310, 40 BITMAP ".\meterex.bmp" TOTAL 50 PIXEL 
   @ 60,  50 BUTTON "+" ACTION ( nActual := oMeter:Set( nActual += 1 ) ) SIZE 25, 20 PIXEL
   @ 60,  80 BUTTON "-" ACTION ( nActual := oMeter:Set( nActual -= 1 ) ) SIZE 25, 20 PIXEL
   @ 60, 110 BUTTON "Rst" ACTION ( nActual := oMeter:Set( 0 ), oMeter:Refresh() ) SIZE 25, 20 PIXEL
   @ 60, 140 BUTTON "Auto" ACTION ( Automatic( oMeter, @nActual ) ) SIZE 70, 20 PIXEL
   @ 60, 215 CHECKBOX oMeter:lInverted PROMPT "inverted" PIXEL SIZE 70, 12 
   @ 60, 290 CHECKBOX oMeter:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12 
   
   // meter 2
   @ 100, 50 METEREX oMeter2 VAR nActual2 SIZE 310, 20 TOTAL 50 PIXEL;
             GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
                                { 1/2, nRGB( 224, 238,237 ), nRGB( 224, 238,237 ) } } ;
             LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE;
             ROUND INVERTED;
             ON PAINT( If( nActual2 == oMeter2:nTotal, Msginfo( "Finished" ), ) ) 
   
   @ 130,  50 BUTTON "+" ACTION ( nActual2 := oMeter2:Set( nActual2 += 1 ) ) SIZE 25, 20 PIXEL
   @ 130,  80 BUTTON "-" ACTION ( nActual2 := oMeter2:Set( nActual2 -= 1 ) ) SIZE 25, 20 PIXEL
   @ 130, 110 BUTTON "Rst" ACTION ( nActual2 := 0, oMeter2:Set( 0 ), oMeter2:Refresh() ) SIZE 25, 20 PIXEL
   @ 130, 140 BUTTON "Auto" ACTION ( Automatic( oMeter2, @nActual2 ) ) SIZE 70, 20 PIXEL
   @ 130, 215 CHECKBOX oMeter2:lInverted PROMPT "inverted" PIXEL SIZE 70, 12 
   @ 130, 290 CHECKBOX oMeter2:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12 


   // meter 3
   @ 180, 50 METEREX oMeter3 VAR nActual3 SIZE 310, 20 TOTAL 50 PIXEL;
             GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } , ;
                              { 1/2, nRGB( 244, 194,  51 ), nRGB( 252, 235,  173 ) } };
             GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
                                { 1/2, nRGB( 224, 238,237 ), nRGB( 224, 238,237 ) } };
             ROUND LINECOLORS CLR_BLACK, CLR_WHITE
             
                
   @ 210,  50 BUTTON "+" ACTION ( nActual3 := oMeter3:Set( nActual3 += 1 ) ) SIZE 25, 20 PIXEL
   @ 210,  80 BUTTON "-" ACTION ( nActual3 := oMeter3:Set( nActual3 -= 1 ) ) SIZE 25, 20 PIXEL
   @ 210, 110 BUTTON "Rst" ACTION ( nActual3 := oMeter3:Set( 0 ), oMeter3:Refresh() ) SIZE 25, 20 PIXEL
   @ 210, 140 BUTTON "Auto" ACTION ( Automatic( oMeter3, @nActual3 ) ) SIZE 70, 20 PIXEL
   @ 210, 215 CHECKBOX oMeter3:lInverted PROMPT "inverted" PIXEL SIZE 70, 12 
   @ 210, 290 CHECKBOX oMeter3:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12 
   
   // meter 4 vertical
   @ 10, 380 METEREX oMeter4 VAR nActual4 SIZE 20, 200 TOTAL 50 PIXEL;
             GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
                                { 1/2, nRGB( 224, 238,237 ), nRGB( 224, 238,237 ) } } ;
             LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE;
             VERTICAL INVERTED
   
   @  10, 415 BUTTON "+" ACTION ( nActual4 := oMeter4:Set( nActual4 += 1 ) ) SIZE 25, 20 PIXEL
   @  40, 415 BUTTON "-" ACTION ( nActual4 := oMeter4:Set( nActual4 -= 1 ) ) SIZE 25, 20 PIXEL
   @  70, 415 BUTTON "Rst" ACTION ( nActual4 := oMeter4:Set( 0 ), oMeter4:Refresh() ) SIZE 25, 20 PIXEL
   @ 100, 415 BUTTON "Automatic" ACTION ( Automatic( oMeter4, @nActual4 ) ) SIZE 70, 20 PIXEL
   @ 130, 415 CHECKBOX oMeter4:lInverted PROMPT "inverted" PIXEL SIZE 70, 12 
   @ 160, 415 CHECKBOX oMeter4:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12    
   
   ACTIVATE WINDOW oWnd

RETURN NIL

FUNCTION Automatic( oMeter, nActual )

   LOCAL n
   LOCAL nFrom := nActual

   FOR n = nFrom TO oMeter:nTotal step 0.001
      nActual = n
      oMeter:Set( nActual )
   NEXT
   nActual = oMeter:nTotal
   oMeter:Set( nActual )
   
RETURN NIL
 

Re: Nueva Clase TMeterEx

Posted: Wed Mar 24, 2010 9:10 pm
by toninhofwi
Hi Daniel.

Very nice job.

Regards,

Toninho.

Re: Nueva Clase TMeterEx

Posted: Wed Mar 24, 2010 10:41 pm
by Armando
Daniel:

Se ve fffffffffffffffffffffenomenal.

Felicitaciones al "cocinero".

Saludos

Re: Nueva Clase TMeterEx

Posted: Thu Mar 25, 2010 12:13 am
by Daniel Garcia-Gil
Trabajando desde recursos

Image

http://www.sitasoft.net/fivewin/samples/meterex2.zip

Code: Select all

#include "fivewin.ch"



FUNCTION MAIN
   
   LOCAL oDlg 
   LOCAL oMeter, oMeter2
   LOCAL nActual := nActual2 := 0
   
   
   DEFINE DIALOG oDlg RESOURCE "METEREX"

   REDEFINE METEREX oMeter VAR nActual ID 100 TOTAL 50 ROUND ROUNDSIZE 6
   REDEFINE BUTTON ID 101 ACTION ( nActual := oMeter:Set( nActual += 1 ) )
   REDEFINE BUTTON ID 102 ACTION ( nActual := oMeter:Set( nActual -= 1 ) )
   REDEFINE BUTTON ID 103 ACTION ( nActual := 0, oMeter:Set( 0 ) )
   REDEFINE BUTTON ID 104 ACTION ( Automatic( oMeter, @nActual ) ) 
   REDEFINE CHECKBOX oMeter:lInverted ID 105 
   REDEFINE CHECKBOX oMeter:lVertical ID 106 
   

   REDEFINE METEREX oMeter2 VAR nActual2 ID 199 TOTAL 50 VERTICAL INVERTED ;
             GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } , ;
                              { 1/2, nRGB( 244, 194,  51 ), nRGB( 252, 235,  173 ) } }
   REDEFINE BUTTON ID 200 ACTION ( nActual2 := oMeter2:Set( nActual2 += 1 ) )
   REDEFINE BUTTON ID 201 ACTION ( nActual2 := oMeter2:Set( nActual2 -= 1 ) )
   REDEFINE BUTTON ID 202 ACTION ( nActual2 := 0, oMeter2:Set( 0 ) )
   REDEFINE BUTTON ID 203 ACTION ( Automatic( oMeter2, @nActual2 ) ) 
   REDEFINE CHECKBOX oMeter2:lInverted ID 204
   REDEFINE CHECKBOX oMeter2:lVertical ID 205 


   ACTIVATE DIALOG oDlg
   
RETURN NIL
   
FUNCTION Automatic( oMeter, nActual )

   LOCAL n
   LOCAL nFrom := nActual

   FOR n = nFrom TO oMeter:nTotal step 0.001
      nActual = n
      oMeter:Set( nActual )
   NEXT
   nActual = oMeter:nTotal
   oMeter:Set( nActual )
   
RETURN NIL   
 
RC...

Code: Select all

METEREX DIALOG MOVEABLE PURE LOADONCALL DISCARDABLE 18, 18, 299, 169
STYLE DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_SYSMENU |WS_CAPTION 
CAPTION "Test Resource TMeterEx"
FONT 8, "Arial"
LANGUAGE LANG_NEUTRAL, 0
{
  CONTROL "",100,"TMETEREX",WS_CHILD |WS_VISIBLE ,17,14,265,14
  CONTROL "+",101,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,17,32,25,20
  CONTROL "-",102,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,48,32,25,20
  CONTROL "Rst",103,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,80,32,25,20
  CONTROL "Auto",104,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,109,37,50,14
  CONTROL "Inverted",105,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,167,29,70,10
  CONTROL "Vertical",106,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,167,42,70,10
  CONTROL "UserDefined",199,"TMETEREX",WS_CHILD |WS_VISIBLE ,17,62,19,102
  CONTROL "+",200,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,63,25,20
  CONTROL "-",201,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,85,25,20
  CONTROL "Rst",202,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,107,25,20
  CONTROL "Auto",203,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,129,50,14
  CONTROL "Inverted",204,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,83,68,70,10
  CONTROL "Vertical",205,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,84,81,70,10
}
 

Re: Nueva Clase TMeterEx

Posted: Thu Mar 25, 2010 1:44 am
by joseluisysturiz
Como siempre espectacular.

Re: Nueva Clase TMeterEx

Posted: Thu Mar 25, 2010 12:24 pm
by acuellar
Hola Daniel, muy bonito gracias.

He compilado el ejemplo con el recurso y da error de sintaxis. Para que version de Fivewin es? Tengo la 9.04

Gracias distinguido

Saludos

Adhemar

Re: Nueva Clase TMeterEx

Posted: Thu Mar 25, 2010 12:27 pm
by Daniel Garcia-Gil
Hola Acuellar


estara disponible para la proxima version de FW (10.3)

gracias.

Re: Nueva Clase TMeterEx

Posted: Thu Mar 25, 2010 12:29 pm
by acuellar
Ok.

Gracias

Adhemar

Re: Nueva Clase TMeterEx

Posted: Thu Mar 25, 2010 12:32 pm
by karinha
Marabilloso Daniel, parabiéns!!

Regards, saludos.

Re: Nueva Clase TMeterEx

Posted: Sat Feb 19, 2011 4:35 pm
by AIDA
Hola

muy bonitos pero como lo aplico en una index

USE DATA\CIUDAD
INDEX ON CIUDAD->NOMBRE TAG "ciudad"

se puede o no se puede :?:

Saluditos :wink:

Re: Nueva Clase TMeterEx

Posted: Sat Feb 19, 2011 4:43 pm
by Marcelo Via Giglio

Re: Nueva Clase TMeterEx

Posted: Sat Feb 19, 2011 7:32 pm
by AIDA
Gracias por el dato pero yo no uso FwCe

lo quiero para PC

Saluditos :wink:

Re: Nueva Clase TMeterEx

Posted: Sat Feb 19, 2011 8:24 pm
by Marcelo Via Giglio

Re: Nueva Clase TMeterEx

Posted: Sat Feb 19, 2011 10:31 pm
by Daniel Garcia-Gil
Aida

tomado del post de FWCE

usando meterex.... recuerda usar la DBF que viene en la carpeta sample

Code: Select all

#include "fivewin.ch"

REQUEST DBFCDX

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

Function Main()

   Local oWnd, oBtn[ 2 ], oMeter, nProg

   USE ( "customer" ) EXCLUSIVE NEW VIA "DBFCDX"

   DEFINE WINDOW oWnd TITLE "Indexing"

   @ 20, 10 BUTTON oBtn[ 1 ] PROMPT "&Index" OF oWnd SIZE 60, 20 PIXEL ;
            ACTION fIndex( oMeter )

   @ 20, 80 BUTTON oBtn[ 2 ] PROMPT "&Exit" OF oWnd SIZE 40, 20 PIXEL ;
            ACTION oWnd:End()

   @ 50,  5 METEREX oMeter VAR nProg OF oWnd SIZE 226, 20 PIXEL

   ACTIVATE WINDOW oWnd

Return Nil

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

Function fIndex( oMeter )

   Local nVar, nStep, nTotal
   Field Last, First

   If File( "Customer.cdx" )
      FErase( "Customer.cdx" )
   EndIf

   nTotal := RecCount()
   nStep := Max( Int( nTotal * .02 ), 1 ) // update meter every 2% of progress is faster than every record
   nVar := 0
   oMeter:nTotal = nTotal
   oMeter:Set( 0 )
   Index On Last + First Tag ( "LASTFIRST" ) To Customer ;
         Eval { || oMeter:Set( nVar += nStep ), SysRefresh(),  .T. } Every nStep

   oMeter:Set( nTotal )

Return Nil

Re: Nueva Clase TMeterEx

Posted: Sat Feb 19, 2011 11:52 pm
by AIDA
Hola Daniel

Funciona super bien :mrgreen:
y se ve muy bonito :!: :!: :!:

muchos tenquius por el ejemplo :D

Gracias :wink: