
Image is my MySQL backup from harbour.
I do not think how to do this on fivewin.
Graph routine is simple, I update each second, to do not slow proccess.
Code: Select all | Expand
/*
ZE_GRAFTEMPO - GRAFICOS DE PROCESSAMENTO
1990.05 - José Quintas
*/
#include "inkey.ch"
#include "set.ch"
#define GRAFMODE 1
#define GRAFTIME 2
#define GRAF_SEC_OLD 1
#define GRAF_SEC_INI 2
#define GRAF_TXT_BAR 3
#define GRAF_TXT_TEXT 4
FUNCTION GrafProc( nRow, nCol )
THREAD STATIC GrafInfo := { 1, "X" }
LOCAL mSetDevice
hb_Default( @nRow, MaxRow() - 1 )
hb_Default( @nCol, MaxCol() - 2 )
IF GrafInfo[ GRAFTIME ] != Time()
mSetDevice := Set( _SET_DEVICE, "SCREEN" )
@ nRow, nCol SAY "(" + Substr( "|/-\", GrafInfo[ GRAFMODE ], 1 ) + ")" COLOR SetColorMensagem()
GrafInfo[ GRAFMODE ] = iif( GrafInfo[ GRAFMODE ] == 4, 1, GrafInfo[ GRAFMODE ] + 1 )
Set( _SET_DEVICE, mSetDevice )
GrafInfo[ GRAFTIME ] := Time()
ENDIF
RETURN .T.
FUNCTION GrafTempo( xContNow, xContTotal )
THREAD STATIC aStatic := { 0, 0, "", "" }
LOCAL nSecondsNow, nSecondsRemaining, nSecondsElapsed, nCont, nPos, cTxt, cCorAnt
LOCAL nPercent, cTexto, mSetDevice
xContNow := iif( xContNow == NIL, "", xContNow )
IF Empty( aStatic[ GRAF_TXT_BAR ] )
aStatic[ GRAF_TXT_BAR ] := Replicate( ".", MaxCol() )
FOR nCont = 1 to 10
nPos := Int( Len( aStatic[ GRAF_TXT_BAR ] ) / 10 * nCont )
cTxt := lTrim( Str( nCont, 3 ) ) + "0%" + Chr(30)
aStatic[ GRAF_TXT_BAR ] := Stuff( aStatic[ GRAF_TXT_BAR ], ( nPos - Len( cTxt ) ) + 1, Len( cTxt ), cTxt )
NEXT
aStatic[ GRAF_TXT_BAR ] := Chr(30) + aStatic[ GRAF_TXT_BAR ]
ENDIF
mSetDevice := Set( _SET_DEVICE, "SCREEN" )
DO CASE
CASE ValType( xContNow ) == "C"
cTexto := xContNow
aStatic[ GRAF_SEC_INI ] := Int( Seconds() )
CASE xContTotal == NIL
nPercent := xContNow
CASE xContNow >= xContTotal
nPercent := 100
CASE xContTotal == 0
nPercent := 0
OTHERWISE
nPercent := xContNow / xContTotal * 100
ENDCASE
xContNow := iif( ValType( xContNow ) != "N", 0, xContNow )
xContTotal := iif( ValType( xContTotal ) != "N", 0, xContTotal )
cCorAnt := SetColor()
SetColor( SetColorMensagem() )
nSecondsNow := Int( Seconds() )
IF nPercent == NIL
aStatic[ GRAF_SEC_OLD ] := nSecondsNow
Mensagem()
@ MaxRow(), 0 SAY aStatic[ GRAF_TXT_BAR ]
aStatic[ GRAF_TXT_TEXT ] := cTexto
ELSEIF nPercent == 100 .OR. ( nSecondsNow != aStatic[ GRAF_SEC_OLD ] .AND. nPercent != 0 )
aStatic[ GRAF_SEC_OLD ] := nSecondsNow
nSecondsElapsed := nSecondsNow - aStatic[ GRAF_SEC_INI ]
DO WHILE nSecondsElapsed < 0
nSecondsElapsed += ( 24 * 3600 ) // Acima de 24 horas
ENDDO
nSecondsRemaining := nSecondsElapsed / nPercent * ( 100 - nPercent )
@ MaxRow()-1, 0 SAY aStatic[ GRAF_TXT_TEXT ] + " " + Ltrim( Transform( xContNow, PicVal(14,0) ) ) + "/" + Ltrim( Transform( xContTotal, PicVal(14,0) ) )
cTxt := "Gasto:"
cTxt += " " + Ltrim( Str( Int( nSecondsElapsed / 3600 ), 10 ) ) + "h"
cTxt += " " + Ltrim( Str( Mod( Int( nSecondsElapsed / 60 ), 60 ), 10, 0 ) ) + "m"
cTxt += " " + Ltrim( Str( Mod( nSecondsElapsed, 60 ), 10, 0 ) ) + "s"
cTxt += Space(3)
cTxt += "Falta:"
cTxt += " " + Ltrim( Str( Int( nSecondsRemaining / 3600 ), 10 ) ) + "h"
cTxt += " " + Ltrim( Str( Mod( Int( nSecondsRemaining / 60 ), 60 ), 10, 0 ) ) + "m"
cTxt += " " + Ltrim( Str( Mod( nSecondsRemaining, 60 ), 10, 0 ) ) + "s"
@ Row(), Col() SAY Padl( cTxt, MaxCol() - Col() - 4 )
GrafProc()
@ MaxRow(), 0 SAY Left( aStatic[ GRAF_TXT_BAR ], Len( aStatic[ GRAF_TXT_BAR ] ) * nPercent / 100 ) COLOR SetColorFocus()
ENDIF
SetColor( cCorAnt )
SET( _SET_DEVICE, mSetDevice )
RETURN .T.
Code: Select all | Expand
USE ( file )
GrafTempo( "processing" )
DO WHILE ! Eof()
GrafTempo( RecNo(), LastRec() )
SKIP
ENDDO
Code: Select all | Expand
USE ( file )
INDEX ON field->x FOR GrafTempo( RecNo(), LastRec() )
Code: Select all | Expand
USE ( File ) INDEX ( file )
nAtual := 0
nTotal := LastRec()
DO WHILE ! Eof()
GrafTempo( nAtual++, nTotal )
SKIP
ENDDO

On minigui I use windows type panel, to me it is like an user control.
It is simple too.
main dialog
Code: Select all | Expand
#include "hmg.ch"
#include "i_altsyntax.ch"
REQUEST HB_CODEPAGE_PTISO
PROCEDURE Main
LOCAL oControl, aControlList := Array(6), nColor, nRow
LOCAL nCurrent := 0, nTotal := 100, xDlg := "A"
DEFINE WINDOW (xDlg) ;
ROW 0 COL 0 ;
WIDTH 1024 HEIGHT 768 ;
TITLE "test" ;
WINDOWTYPE MAIN ;
ON INIT SetBackImage( xDlg )
FOR EACH oControl, nRow, nColor IN aControlList, ;
{ 80, 160, 240, 320, 400, 480 }, ;
{ COLOR_SKYBLUE, COLOR_PERU, COLOR_GOLD, COLOR_VIOLET, COLOR_PEACHPUFF, COLOR_YELLOWGREEN }
oControl := GraphTime():New( "A", nRow, 10, 500, 50, "working", nColor )
NEXT
DEFINE BUTTON BUTTON_1
ROW 40
COL 10
CAPTION 'Click Me!'
ACTION AEval( aControlList, { | e | e:SetValues( nCurrent += 2, nTotal ) } )
DEFAULT .T.
END BUTTON
END WINDOW
ACTIVATE WINDOW A
RETURN
FUNCTION SetBackImage( xDlg )
LOCAL hBrush
DoMethod( xDlg, "DISABLEUPDATE" )
DEFINE BKGBRUSH hBrush PATTERN IMAGE "imw10.png" IN ( xDlg )
DoMethod( xDlg, "ENABLEUPDATE" )
(hBrush)
RETURN Nil
Code: Select all | Expand
/*
graphtime - graphic with time calculate
*/
#include "hmg.ch"
#include "i_altsyntax.ch"
#include "i_wincolor.ch"
#include "hbclass.ch"
STATIC nWindow := 1
CREATE CLASS GraphTime
VAR xDlg
VAR Parent
VAR cTimeShow INIT Time()
VAR nSecondsInit
VAR nSecondsOld
VAR cText
METHOD New( Parent, nRow, nCol, nWidth, nHeight, cTitle, xColor )
METHOD SetValues( nCurrent, nTotal )
ENDCLASS
METHOD SetValues( nCurrent, nTotal ) CLASS GraphTime
LOCAL nSecNow, nSecElapsed, nSecRemaining, nPercent, nNewWidth, cCaption
nCurrent := Min( nCurrent, nTotal )
nSecNow := Int( Seconds() )
IF nSecNow != ::nSecondsOld .AND. nCurrent != 0
nNewWidth := Int( GetProperty( ::xDlg, "label1", "WIDTH" ) * nCurrent / nTotal )
SetProperty( ::xDlg, "label3", "WIDTH", nNewWidth )
::nSecondsOld := nSecNow
nSecElapsed := nSecNow - ::nSecondsInit
nSecRemaining := nSecElapsed / nCurrent * ( nTotal - nCurrent )
nPercent := nCurrent * 100 / nTotal
SetProperty( ::xDlg, "label1", "VALUE", ;
Ltrim( Str( nCurrent ) ) + "/" + Ltrim( Str( nTotal ) ) + " " + ;
"Elapsed " + SecToTime( nSecElapsed ) + ;
" Remain " + SecToTime( nSecRemaining ) )
cCaption := ::cText + " " + Ltrim( Str( nPercent ) ) + "%"
SetProperty( ::xDlg, "label2", "VALUE", cCaption )
SetProperty( ::xDlg, "label3", "VALUE", cCaption )
ENDIF
RETURN Nil
METHOD New( Parent, nRow, nCol, nWidth, nHeight, cTitle, xColor ) CLASS GraphTime
::cText := cTitle
::Parent := Parent
::nSecondsInit := Int( Seconds() )
::nSecondsOld := Int( Seconds() )
::xDlg := "GTIME" + StrZero( nWindow++, 3 )
DEFINE WINDOW ( ::xDlg ) ;
ROW nRow ;
COL nCol ;
WIDTH nWidth ;
HEIGHT nHeight ;
WINDOWTYPE PANEL
DEFINE LABEL ( "label1" )
PARENT ( ::xDlg )
ROW 10
COL 10
VALUE ""
BORDER .T.
WIDTH nWidth - 30
HEIGHT 20
BORDER .T.
END LABEL
DEFINE LABEL ( "label2" )
PARENT ( ::xDlg )
ROW 30
COL 10
VALUE ::cText
BORDER .T.
WIDTH nWidth - 30
HEIGHT 20
BORDER .T.
END LABEL
DEFINE LABEL ( "label3" )
PARENT ( ::xDlg )
ROW 30
COL 10
VALUE ::cText
WIDTH 1
HEIGHT 20
BACKCOLOR xColor
BORDER .T.
END LABEL
END WINDOW
RETURN Self
For Graph and for scroll text.
Note: post routines because they can be a reference to new ones.
For MySQL backup I get quantity and record count.
Code: Select all | Expand
Mensagem( "Fazendo backup da base SQL" )
WITH OBJECT cnSQL
:Execute( "SHOW PROCEDURE STATUS WHERE db = DATABASE()" )
nTotal += :RecordCount()
:CloseRecordset()
:Execute( "SHOW FUNCTION STATUS WHERE db = DATABASE()" )
nTotal += :RecordCount()
:CloseRecordset()
:Execute( "SELECT table_name FROM information_schema.TABLES" + ;
" WHERE table_schema = " + StringSQL( Lower( AppEmpresaApelido() ) ) + ;
" AND TABLE_TYPE = 'BASE TABLE'" )
DO WHILE ! :Eof()
nTotal += 1
oTableRec := cnSQL:ExecuteReturnRS( "SELECT COUNT(*) AS QTD FROM " + cnSQL:String( "table_name" ) )
nTotal += oTableRec:Fields( "QTD" ):Value
oTableRec:Close()
:MoveNext()
ENDDO
:CloseRecordset()
ENDWITH
GrafTempo( "Backup SQL" )
nAtual := 0
hFileOutput := fCreate( "backup" + Str( nBackupFileNum, 1 ) + ".sql", FC_NORMAL )
...
GrafTempo( nAtual, nTotal )
...