FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Progress Bars, no funciona correctamente (Solucionado)
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Progress Bars, no funciona correctamente (Solucionado)
Posted: Wed Jul 16, 2014 03:08 PM
Progress Bars, no funciona correctamente.

Code (fw): Select all Collapse
#include "FiveWin.ch"

#define PBM_SETRANGE32     1030

function Main()

   local oDlg, oProg1, oProg2
   
   DEFINE DIALOG oDlg TITLE "Progress Bars"
   
   @ 1, 1 PROGRESS oProg1 SIZE 80, 12

   @ 1, 20 PROGRESS oProg2 SIZE 12, 50 VERTICAL
   
   @ 3,  9 BUTTON "Ok" ACTION oDlg:End()
   
   oDlg:bStart = { || Increase( oProg1, oProg2 ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ) )
   
return nil   

function Increase( oProg1, oProg2 )

   local n := 0

   // Maestro porque no funciona con 100? No esta incorrecto?
   for n = 1 to 100 // 111 // ???

      //oProg1:StepIt()
      //oProg2:StepIt()

      oProg1:SetPos( n )
      oProg2:SetPos( n )

      Sleep( 50 )

      SysRefresh()

   next
   
return nil


Gracias, saludos

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Progress Bars, no funciona correctamente.
Posted: Mon Jul 21, 2014 03:21 PM

Nadie?

Gracias.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Mon Jul 21, 2014 04:14 PM
Joao,

Es un problema relacionado con los temas de Windows y que de momento no hemos descubierto la razón.

Prueba a construir tu ejemplo sin usar

1 24 "WinXP/WindowsXP.Manifest"

y verás como funciona bien. Sin embargo al usar el manifest, falla.

Habrá que buscar nuevamente en google para ver cual pueda ser la razón...



regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Progress Bars, no funciona correctamente.
Posted: Mon Jul 21, 2014 05:52 PM
C:\FWH1306\SAMPLES\PROGTIME.PRG

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oDlg, oProg
   
   DEFINE DIALOG oDlg TITLE "Progress and timer"

   @ 1, 3 PROGRESS oProg POSITION 0 SIZE 120, 10
   
   @ 2.5, 10 BUTTON "End" ACTION oDlg:End()

   /*
   ACTIVATE DIALOG oDlg CENTER ;  // funciona
      ON INIT ( oProg:SetRange( 1, 95 ), Timer( oDlg, oProg ) )
   */

   ACTIVATE DIALOG oDlg CENTER ;  // No funciona
      ON INIT ( oProg:SetRange( 1, 100 ), Timer( oDlg, oProg ) )
   
return nil   

function Timer( oDlg, oProg )
   
   local oTmr
   
   DEFINE TIMER oTmr INTERVAL 1000 ;
      ACTION ( oProg:nPosition += 5, MsgBeep(),;
             If( oProg:nPosition == 100, oTmr:End(),) ) OF oDlg

   ACTIVATE TIMER oTmr

return nil
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Progress Bars, no funciona correctamente.
Posted: Mon Jul 21, 2014 06:01 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 117
Joined: Mon Aug 13, 2007 05:22 PM
Re: Progress Bars, no funciona correctamente.
Posted: Mon Jul 21, 2014 07:51 PM

João
Reclamo disso desde 2009 conforme link abaixo

viewtopic.php?f=6t=14632p=80695hilit=oProg2%3ASetRange+0%2C+111+#p80695

Ja desisti de usar tal componente.

&&&

Marcelo Ferro da Silveira

Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8

SqlLib /xMate/WS
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 06:37 AM
A ver, estos son los mensajes que tenemos para usar este control:

#define PBM_SETRANGE (WM_USER+1)
#define PBM_SETPOS (WM_USER+2)
#define PBM_DELTAPOS (WM_USER+3)
#define PBM_SETSTEP (WM_USER+4)
#define PBM_STEPIT (WM_USER+5)
#if (_WIN32_IE >= 0x0300)
#define PBM_SETRANGE32 (WM_USER+6) // lParam = high, wParam = low
typedef struct
{
int iLow;
int iHigh;
} PBRANGE, *PPBRANGE;
#define PBM_GETRANGE (WM_USER+7) // wParam = return (TRUE ? low : high). lParam = PPBRANGE or NULL
#define PBM_GETPOS (WM_USER+8)
#if (_WIN32_IE >= 0x0400)
#define PBM_SETBARCOLOR (WM_USER+9) // lParam = bar color
#endif // _WIN32_IE >= 0x0400
#define PBM_SETBKCOLOR CCM_SETBKCOLOR // lParam = bkColor
#endif // _WIN32_IE >= 0x0300

#if (_WIN32_WINNT >= 0x0501)
#define PBS_MARQUEE 0x08
#define PBM_SETMARQUEE (WM_USER+10)
#endif // _WIN32_WINNT >= 0x0501
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 06:40 AM

en los ejemplos que ha mostrado Joao usan:

progressBar1.Maximum = 100;
progressBar1.Step = 1;
progressBar1.Value = 0;

Cual de esos mensajes (de mi post anterior) se correspondería con .Maximum y con .Value ?

.Step parece ser PBM_SETSTEP

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 06:53 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 07:06 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 07:07 AM
Primero se establece el rango:

SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, cb / 2048));

En FWH:
Code (fw): Select all Collapse
   METHOD SetRange( nMin, nMax ) INLINE ;
          SendMessage( ::hWnd, PBM_SETRANGE, 0, nMakeLong( nMin, nMax ) ),;
          ::nMin := nMin, ::nMax := nMax


cb es lo que mide un fichero

Luego se establece el Step (paso):

SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 1, 0);

En FWH:
Code (fw): Select all Collapse
   METHOD SetStep( nStepInc ) INLINE ;
          SendMessage( ::hWnd, PBM_SETSTEP, ::nStep := nStepInc )


y desde un bucle se llama a:

SendMessage(hwndPB, PBM_STEPIT, 0, 0);

En FWH:
Code (fw): Select all Collapse
   METHOD StepIt() INLINE SendMessage( ::hWnd, PBM_STEPIT ), ::nPos += ::nStep


eso es todo...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 01:09 PM
En este ejemplo estamos siguiendo el orden usado en el ejemplo de Microsoft:

Me da la impresión que tiene que existir un mensaje para decirle a Windows que los incrementos los pinte con un rango menor. Al llegar a 100 le falta y al pasar a 101 le sobra, luego es como si en ese paso recorre demasiado...

Code (fw): Select all Collapse
#include "FiveWin.ch"

#define PBM_SETRANGE32     1030

function Main()

   local oDlg, oProg1, oProg2
   
   DEFINE DIALOG oDlg TITLE "Progress Bars"
   
   @ 1, 1 PROGRESS oProg1 SIZE 80, 12

   @ 1, 20 PROGRESS oProg2 SIZE 12, 50 VERTICAL
   
   @ 3,  9 BUTTON "Ok" ACTION oDlg:End()
   
   oDlg:bStart = { || Increase( oProg1, oProg2 ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ) )
   
return nil   

function Increase( oProg1, oProg2 )

   local n := 0

   for n = 1 to 101 // 100

      oProg1:StepIt()
      oProg2:StepIt()

      Sleep( 30 )

      SysRefresh()

   next
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 01:35 PM

I really don't understand this control behavior.

All that is needed is to synch oProg1:SetRange( 0, x ), oProg1:SetStep( y ) and for n = 1 to z

x, y and z must keep a relationship, but I can't find it :-(

I appreciate any suggestion

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 01:54 PM
Antonio,

Te traduzco un mensaje que he encontrado por ahi, por si te diera una pista. El asunto según parece es viejo, y viene de cuando Windows Vista.

the problem of progressbar in Vista is that windows ignores the
value assigned to it, and on your own using a timer to go
raising the bar at your leisure. So when you assign your 100%, the
yet he goes where he pleases. The only way I've found of
force him to show the bar to 100%, change the limit to 1 and the value
also 1 Eg.:

oProgressBar1 ::: nMax: = 1
oProgressBar1 ::: nValue: = 1

However, see a bar jump from where he was,
to 100% hit.


Saludos
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Progress Bars, no funciona correctamente.
Posted: Tue Jul 22, 2014 01:59 PM
Paco,

ok, solucionado :-)

Este ejemplo funciona correctamente, gracias!

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oDlg, oProg1, oProg2
   
   DEFINE DIALOG oDlg TITLE "Progress Bars"
   
   @ 1, 1 PROGRESS oProg1 SIZE 80, 12

   @ 1, 20 PROGRESS oProg2 SIZE 12, 50 VERTICAL
   
   @ 3,  9 BUTTON "Ok" ACTION oDlg:End()
   
   oDlg:bStart = { || Increase( oProg1, oProg2 ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ) )
   
return nil   

function Increase( oProg1, oProg2 )

   local n := 0

   for n = 1 to 116 

      oProg1:SetPos( n )
      oProg2:SetPos( n )

      Sleep( 30 )

      SysRefresh()

   next
   
return nil


regards, saludos

Antonio Linares
www.fivetechsoft.com