WINPROG Commands
Previous topic  First topic  Next topic


WINPROG command offers a group of sub-commands to generate a very simple progress bar.
El comando WINPROG ofrece un grupo de sub-comandos para generar una barra de progreso verdaderamente simple.

Look, you can create a complete progress bar by coding tree commands:
Mire, usted puede crear una barra de progreso completa mediante la codificación de solo 3 comandos:

WINPROG OPEN to create the container modal window
WINPROG SET VALUE TO <nValue> to set value of progress bar
WINPROG CLOSE to release the container modal window

WINPROG OPEN para crear la ventana MODAL contenedora
WINPROG SET VALUE TO <nValue> para setear el valor de la barra de progreso
WINPROG CLOSE para liberar la ventana MODAL contenedora


Real working sample:
Ejemplo funcional:

FUNCTION myProcess()
   LOCAL nInx := 0
   WINPROG OPEN
   DO WHILE nInx < 101
      nInx++
      WINPROG SET VALUE TO nInx
      mg_wait( 0.2 )
   ENDDO
   WINPROG CLOSE
RETURN NIL


Obviously, you can customize some properties, like windows CAPTION, ROW, COL, WIDTH, HEIGHT, RANGEMIN, RANGEMAX
Obviamente, usted puede personalizar algunas propiedades, como ser el CAPTION de la ventana, o ROW, COL, WIDTH, HEIGHT, RANGEMIN, RANGEMAX

eg: WINPROG SET CAPTION TO "Test"

In addition, you can add a STOP button and you can add a CONFIRMSTOP question:

Adicionalmente, usted puede agregar un boton de STOP y ademas, puede agregarle un boton de CONFIRMSTOP antes de detener el proceso

FUNCTION myProcess()
   LOCAL nInx := 0
   
LOCAL lStop
   WINPROG OPEN STOP CONFIRMSTOP
   DO WHILE nInx < 101
      nInx++
      WINPROG SET VALUE TO nInx
STOPVAR lStop
      IF lStop
         EXIT
      ENDIF

      mg_wait( 0.2 )
   ENDDO
   WINPROG CLOSE
RETURN NIL



Other useful use is for WAIT modal windows. To implement it, you only need to coded TEXT parameter.
Then, instead a progress bar, the modal window will show a LABEL with the TEXT set by VALUE property.

Otro uso muy interesante es utilizar WINPROG para construir una ventana modal de espera. Para ello solo hay que agregar el parámetro TEXT
Entonces, en lugar de una barra de progreso se mostrará un texto (LABEL) que podrá ser seteado mediante la propiedad VALUE


eg. with static TEXT
ej. con texto fijo

FUNCTION myProcess()
   WINPROG OPEN
TEXT
   WINPROG SET ALIGN TO Qt_AlignCenter
   WINPROG SET VALUE TO "Wait..."
...
Here code your heavy process
...

   WINPROG CLOSE
RETURN NIL



eg. with dynamic TEXT
ej. con texto dinámico



FUNCTION myProcess()
   LOCAL nInx := 0
   LOCAL nMax := 60
   LOCAL lStop
   WINPROG OPEN
TEXT STOP CONFIRMSTOP
   
WINPROG SET ALIGN TO Qt_AlignCenter
   DO WHILE nInx < nMax
      nInx++
      WINPROG SET VALUE TO
allTrim( str( nInx ) ) + " OF " + allTrim( str( nMax ) ) STOPVAR lStop
      IF lStop
         EXIT
      ENDIF
      mg_wait( 0.2 )
   ENDDO
   WINPROG CLOSE
RETURN NIL



All WINPROG OPEN options are:
Todas las opciones del comando WINPROG OPEN son:

WINPROG OPEN [ TEXT ] [ STOP ] [ CONFIRMSTOP ]


This is a complete sample to show how change a field of all records from a DBF table (pay special attention to WINPROG commands of add100() function):
Este es un ejemplo completo para mostrar como cambiar un campo de todos los registros de una tabla DBF (preste especial atención a los comandos WINPROG de la función add100())



#include "marinas-gui.ch"

Function main()
   Request DBFCDX , DBFFPT
   Rddsetdefault( "DBFCDX" )

   HB_CDPSELECT( "UTF8" )

   CREATE WINDOW d_window
      ROW 10
      COL 10
      WIDTH 500
      HEIGHT 600
      MAIN .T.

      createDBF()
      dbUseArea( .T. , , "br1" , "br1" )

      CREATE IMAGE
         ROW 0
         COL 0
         WIDTH mg_get( "d_window" , "width" )
         HEIGHT mg_get( "d_window" , "height" )
         PICTURE mg_getDefaultIconName()
         STRETCH .T.
      END IMAGE

      CREATE BROWSE br1
         ROW 10
         COL 110
         WIDTH 280
         HEIGHT 500
         WORKAREA "br1"
      END BROWSE

      CREATE BUTTON
         ROW 550
         COL 150
         WIDTH 200
         CAPTION "Add $100 to Price column"
         ONCLICK Add100()
      END BUTTON

   END WINDOW

   mg_do( "d_window" , "center"    )
   mg_do( "d_window" , "activate" )

   br1->( dbCloseArea() )

RETURN NIL

FUNCTION createDBF()
   LOCAL nInx
   LOCAL aStruct := { ;
            { "name", "C", 12, 0 }, ;
            { "price", "N", 10, 0 } ;
            }
   fErase( "br1.dbf" )
   fErase( "br1.fpt" )
   dbCreate( "br1", aStruct )
   dbUseArea( .T. , , "br1" , "br1" )
   FOR nInx:=1 TO 50000
      br1->(dbappend())
      br1->name:="Item_" + allTrim( str( nInx ) )
      br1->price:=nInx
   NEXT
   br1->( dbcommit() )
   br1->( dbCloseArea() )
RETURN .T.

FUNCTION add100()
   LOCAL lStop
   LOCAL nValuePrev := br1->( recNo() )
   WINPROG OPEN STOP CONFIRMSTOP
   mg_set( "d_window" , "br1", "disableSync" , .T. )
   mg_set( "d_window" , "br1", "disableEvents" , .T. )
   br1->( dbGoTop() )
   DO WHILE !eof()
      WINPROG SET CAPTION TO "Adding $100 -> " + allTrim( str( br1->( recNo() ) ) ) + " of " + allTrim( str( br1->( recCount() ) ) )
      WINPROG SET VALUE TO ( br1->( recNo() ) * 100 ) / br1->( recCount() ) STOPVAR lStop
      REPLACE br1->price WITH br1->price + 100
      IF lStop
         EXIT
      ENDIF
      br1->( dbSkip( 1 ) )
   ENDDO
   br1->( dbGoTo( nValuePrev ) )
   mg_set( "d_window" , "br1", "disableSync" , .f. )
   mg_set( "d_window" , "br1", "disableEvents" , .f. )
   mg_do( "d_window" , "br1", "refresh" )
   WINPROG CLOSE
RETURN .T.




Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: April 27
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic