Page 1 of 2

Progress Bars, no funciona correctamente (Solucionado)

PostPosted: Wed Jul 16, 2014 3:08 pm
by karinha
Progress Bars, no funciona correctamente.

Code: Select all  Expand view

#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


Re: Progress Bars, no funciona correctamente.

PostPosted: Mon Jul 21, 2014 3:21 pm
by karinha
Nadie?

Gracias.

Re: Progress Bars, no funciona correctamente.

PostPosted: Mon Jul 21, 2014 4:14 pm
by Antonio Linares
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...

Image

Image

Re: Progress Bars, no funciona correctamente.

PostPosted: Mon Jul 21, 2014 5:52 pm
by karinha
C:\FWH1306\SAMPLES\PROGTIME.PRG

Code: Select all  Expand view

#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
 

Re: Progress Bars, no funciona correctamente.

PostPosted: Mon Jul 21, 2014 6:01 pm
by karinha

Re: Progress Bars, no funciona correctamente.

PostPosted: Mon Jul 21, 2014 7:51 pm
by marca
João
Reclamo disso desde 2009 conforme link abaixo

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


Ja desisti de usar tal componente.

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 6:37 am
by Antonio Linares
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

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 6:40 am
by Antonio Linares
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

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 6:53 am
by Antonio Linares

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 7:06 am
by Antonio Linares

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 7:07 am
by Antonio Linares
Primero se establece el rango:

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

En FWH:
Code: Select all  Expand view
  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: Select all  Expand view
  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: Select all  Expand view
  METHOD StepIt() INLINE SendMessage( ::hWnd, PBM_STEPIT ), ::nPos += ::nStep


eso es todo...

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 1:09 pm
by Antonio Linares
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: Select all  Expand view
#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
 

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 1:35 pm
by Antonio Linares
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

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 1:54 pm
by hmpaquito
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

Re: Progress Bars, no funciona correctamente.

PostPosted: Tue Jul 22, 2014 1:59 pm
by Antonio Linares
Paco,

ok, solucionado :-)

Este ejemplo funciona correctamente, gracias!

Code: Select all  Expand view
#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


Image