Progress bar windows 10 animation

Progress bar windows 10 animation

Postby AntoninoP » Thu Sep 28, 2017 2:05 pm

Hello,
I tried a modified version of progres1.prg that create a progress bar directly, in this way:

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 ), ;
                CREATEPROGRESS(oDlg:hWnd) )
   
return nil  

function Increase( oProg1, oProg2 )

   local n  
   for n = 1 to 11
      oProg1:SetPos( n*10 )
      oProg2:SetPos( n*10 )
      Sleep( 50 )
      SysRefresh()
   next  
return nil

//*
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <CommCtrl.h>

HB_FUNC( CREATEPROGRESS )
{
#ifndef _WIN64
   HWND hWnd = ( HWND ) hb_parnl( 1 );
#else
   HWND hWnd = ( HWND ) hb_parnll( 1 );
#endif
   HWND hProgress = CreateWindow("msctls_progress32", "progress", WS_CHILD | WS_VISIBLE | WS_TABSTOP |PBS_SMOOTH, 12, 80, 160, 24, hWnd, 0,
      (HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE), 0);
   SendMessage(hProgress, PBM_SETPOS, 50, 0);
   hb_retnl(1);
}

#pragma ENDDUMP


What i see, is the the direct create window has an animation (on windows 10) the other 2 does not.

Image

I tried to fix it and I was not able to do it :cry:

any idea?
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Progress bar windows 10 animation

Postby karinha » Thu Sep 28, 2017 3:09 pm

Code: Select all  Expand view

SendMessage(hProgress, PBM_SETPOS, 100, 0);  
 


??
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7822
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Progress bar windows 10 animation

Postby AntoninoP » Thu Sep 28, 2017 3:29 pm

karinha wrote:
Code: Select all  Expand view

SendMessage(hProgress, PBM_SETPOS, 100, 0);  
 

The problem is not the progress half full (or half empty :lol: ) the problem is the animation that does not work.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Progress bar windows 10 animation

Postby karinha » Thu Sep 28, 2017 3:42 pm

test please

Code: Select all  Expand view

#Include "FiveWin.Ch"

STATIC oDlg, oTimerR, lDesliga := .F., oWnd, oTimerP
STATIC oFnt, oSaida

FUNCTION TEM_PROGRESS()

   LOCAL oProgress

   DEFINE FONT oFnt      NAME "Arial"         SIZE 08,  20 BOLD

   DEFINE DIALOG oDlg FROM 0,0 TO 250,500 TITLE "Test Timer" PIXEL

   oDlg:lHelpIcon := .F.

   oProgress := TProgress():New(50,00,oDlg,0,CLR_RED,CLR_WHITE,.t.,.f.,oDlg:nWidth,8,,.f.,.f.)

   @ 005, 017 BUTTON oSaida PROMPT "&Exit" OF oDlg SIZE 40, 14         ;
              ACTION ( oDlg:End ) CANCEL

   oSaida:cToolTip := OemToAnsi( "Exit" )

   SET FONT OF oSaida   TO oFnt

   ACTIVATE DIALOG oDlg CENTERED                                        ;
            ON INIT( ACIONA_TIMER( oWnd, oProgress ) )

   IF lDesliga
      oTimerR:DeActivate()
      oTimerP:DeActivate()
   ENDIF

   oFnt:End()

RETURN NIL

STATIC FUNCTION ACIONA_TIMER( oWnd, oProgress )

   DEFINE TIMER oTimerP INTERVAL 1000 OF oDlg                        ;
          ACTION MOSTRA_TIMER( oWnd, oProgress )

   ACTIVATE TIMER oTimerP

RETURN NIL

STATIC FUNCTION MOSTRA_TIMER( oWnd, oProgress )

   LOCAL oFont

   DEFINE FONT oFont NAME "Arial" SIZE  0, -70 BOLD
   DEFINE FONT oFnt  NAME "Arial" SIZE 08,  20 BOLD

   DEFINE TIMER oTimerR INTERVAL 1500                                    ;
          ACTION ExibeTimer( oProgress )

   ACTIVATE TIMER oTimerR

   SET FONT OF oDlg   TO oFont
   SET FONT OF oSaida TO oFnt

   oFont:End()

   lDesliga := .T.  //-> Para Desligar o Timer

   oTimerP:DeActivate()

RETURN NIL

FUNCTION ExibeTimer( oProgress )

   IF ISWINDOWVISIBLE( oDlg:hWnd )

      oProgress:SetRange( 0, 200 )
      oProgress:SetPos( 100 )
     
   ENDIF

RETURN NIL
 
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7822
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Progress bar windows 10 animation

Postby cnavarro » Thu Sep 28, 2017 4:17 pm

Antonino, also try this

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, oDlg ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ), ;
                CREATEPROGRESS( oDlg:hWnd ) )
   
return nil  

function Increase( oProg1, oProg2, oDlg )

   local n  
   for n = 1 to 11
      oProg1:SetPos( n*10 )
      oProg2:SetPos( n*10 )
      CREATEPROGRESS( oDlg:hWnd )
      Sleep( 500 )
      SysRefresh()
   next  
return nil

#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <CommCtrl.h>

static HWND hProgress;

HB_FUNC( CREATEPROGRESS )
{
#ifndef _WIN64
   HWND hWnd = ( HWND ) hb_parnl( 1 );
#else
   HWND hWnd = ( HWND ) hb_parnll( 1 );
#endif
   COLORREF bColor  = RGB( 255, 0, 0 );
   COLORREF bColor1 = RGB( 255, 255, 0 );
   if ( !hProgress )
   {
   hProgress = CreateWindow( "msctls_progress32", "progress", WS_CHILD | WS_VISIBLE | WS_TABSTOP| PBS_SMOOTH, 12, 80, 160, 24, hWnd, 0,
      ( HINSTANCE ) GetWindowLong( hWnd, GWL_HINSTANCE ), 0);
   SendMessage( hProgress, PBM_SETRANGE32, 0, 1000);
   SendMessage( hProgress, PBM_SETBARCOLOR, 0, bColor );
   SendMessage( hProgress, PBM_SETBKCOLOR, 0, bColor1 );
   }
   else
   {
   //SendMessage( hProgress, PBM_SETPOS, 50, 0 );
   SendMessage( hProgress, PBM_DELTAPOS, 100, 0 );
   }
   
   hb_retnl( ( LONG ) hProgress );
}

#pragma ENDDUMP

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Progress bar windows 10 animation

Postby AntoninoP » Wed Dec 20, 2017 10:39 am

Hello,
I think there was a misunderstand, I don't want remove animation from my progress bar, I want add animation in FiveWin's progress bar.
I did some tests, and arrived to this code:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "Constant.ch"

#define PBM_SETPOS        1026
#define PBM_SETRANGE      1025
#define PBM_SETMARQUEE    1034

#define PBS_MARQUEE       8

CLASS TMyProgres FROM TControl
    METHOD New( nTop, nLeft, oWnd, lPixel, nWidth, nHeight)
    METHOD cToChar() INLINE ::Super:cToChar( "msctls_progress32" )
    METHOD SetPos(nPos) INLINE  SendMessage( ::hWnd, PBM_SETPOS, nPos )
   METHOD SetRange( nMin, nMax ) INLINE SendMessage( ::hWnd, PBM_SETRANGE, 0, nMakeLong( nMin, nMax ) )
endclass

METHOD New( nTop, nLeft, oWnd, lPixel, nWidth, nHeight, lMarquee) CLASS TMyProgres
   DEFAULT nTop     := 0, nLeft := 0,;
           oWnd     := GetWndDefault(),;
           lPixel   := .f.,;
           nWidth   := 200, nHeight := 21,;
           lMarquee := .F.

   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP,If( lMarquee, PBS_MARQUEE, 0 ) )
                     
   ::nId       = ::GetNewId()
   ::oWnd      = oWnd
   ::nTop      = If( lPixel, nTop, nTop * SAY_CHARPIX_H )
   ::nLeft     = If( lPixel, nLeft, nLeft * SAY_CHARPIX_W )
   ::nBottom   = ::nTop + nHeight - 1
   ::nRight    = ::nLeft + nWidth - 1
   
   ::hWnd := CREATEWINDOW("msctls_progress32",::cCaption,::nStyle, ::nLeft, ::nTop, ::nRight - ::nLeft + 1, ;
                                ::nBottom - ::nTop + 1,oWnd:hWnd,0)
    //::Link() //<-- With this no animation, without this bLClicked does not work
   ::Default()
   
   if lMarquee
    SendMessage(::hWnd,PBM_SETMARQUEE,1,0)
   endif
   
return self

function Main()
   local oDlg, oProg1, oProg2, oPrgCustom, oPrgCustom2  
   DEFINE WINDOW oDlg TITLE "Progress Bars" FROM 100,100 to 400,350 PIXEL
   @ 30, 30 PROGRESS oProg1 SIZE 160, 24 PIXEL
   @ 30, 200 PROGRESS oProg2 SIZE 24, 160 VERTICAL PIXEL
   oPrgCustom := TMyProgres():New(90,30,,.t.,160,24)
   oPrgCustom:bLClicked := {|| MsgInfo("Click") }
   oPrgCustom2 := TMyProgres():New(150,30,,.t.,160,24, .T.)
   //@ 150,30 PROGRESS oPrgCustom2 SIZE 160,24 MARQUEE PIXEL
   //oPrgCustom2:SetMarquee( .T. ) FiveWin Marquee does not works here (in progres2 sample it works, but I don't know how)
   @ 210, 80 BUTTON "Ok" ACTION oDlg:End() SIZE 80,30 PIXEL
   ACTIVATE WINDOW oDlg ON INIT Increase( oProg1, oProg2, oPrgCustom, oDlg )
return nil  

function Increase( oProg1, oProg2, oPrgCustom, oDlg )
   local n,c    
   oProg1:SetRange( 0, 100 )
   oProg2:SetRange( 0, 100 )
   oPrgCustom:SetRange( 0, 100 )
   
   for n = 1 to 5
      oProg1:SetPos( n*10 )
      oProg2:SetPos( n*10 )
      oPrgCustom:SetPos( n*10 )
      for c = 1 to 10
        Sleep( 50 )
        SysRefresh()
      next
   next  
   //oDlg:End()
return nil

that produce this window:
Image
The top and the right progress are TProgress the other two are TMyProgress, we have a smooth filling and a background animation...
I locate the animation killer in Link method of TWindow, that calls XChangeProc that is not provided...
Maybe there is some message ignored or overwritten that make the animation not working...
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Progress bar windows 10 animation

Postby Antonio Linares » Wed Dec 20, 2017 11:09 am

Antonino,

> Maybe there is some message ignored or overwritten that make the animation not working...

Yes, probably. Thank you for your findings.

In the meantime, your new class is working nicely. Many thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Progress bar windows 10 animation

Postby AntoninoP » Wed Dec 20, 2017 11:16 am

In my class does not works the bLClicked or other callbacks... So it can be a workaround but with heavy limitations...
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Progress bar windows 10 animation

Postby Antonio Linares » Wed Dec 20, 2017 11:22 am

Please try adding these methods in Class TProgress:

METHOD Display() VIRTUAL

METHOD Paint() VIRTUAL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Progress bar windows 10 animation

Postby AntoninoP » Wed Dec 20, 2017 11:34 am

I found a fix, if we add the method HandleEvent to TProgress in this way
Code: Select all  Expand view
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TProgres
   if nMsg == WM_TIMER
      return nil
   endif
return ::Super:HandleEvent( nMsg, nWParam, nLParam )

Animation works! :D :D

PS. I copied it from TAnimate 8)
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Progress bar windows 10 animation

Postby Antonio Linares » Wed Dec 20, 2017 11:57 am

Great! :-D

Many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Progress bar windows 10 animation

Postby Antonio Linares » Wed Dec 20, 2017 12:02 pm

Fix included for next FWH version

many details to remember all of them ;-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Progress bar windows 10 animation

Postby AntoninoP » Wed Dec 20, 2017 12:05 pm

Another thing, I would change the SetMarquee in this way:

Code: Select all  Expand view
METHOD SetMarquee( lOnOff )  CLASS TProgress
   ::WinStyle(PBS_MARQUEE, lOnOff)
   SendMessage(::hWnd,PBM_SETMARQUEE,iif(lOnOff,1,0),0)
return nil


then change the TProgress:new in the same way...
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Progress bar windows 10 animation

Postby Antonio Linares » Thu Dec 21, 2017 9:37 am

Antonino,

Already implemented for next FWH build, many thanks

> then change the TProgress:new in the same way...

I don't understand what you mean exactly
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Progress bar windows 10 animation

Postby AntoninoP » Thu Dec 21, 2017 1:06 pm

About TProgress:New
First thing the nStyle shoud has PSB_MARQUEE not PBM_SETMARQUEE:
Code: Select all  Expand view
  ::nStyle    = nOR( WS_CHILD, WS_VISIBLE,;
                      If( lDesign, WS_CLIPSIBLINGS, 0 ),;
                      If( lVertical, PBS_VERTICAL, 0 ), WS_TABSTOP,;
                      If( lMarquee, PBS_MARQUEE, 0 ) )

Then need to call the send message:
Code: Select all  Expand view
  if ! Empty( oWnd:hWnd )
      ::Create( CTRL_CLASS )
      oWnd:AddControl( Self )
      SendMessage(::hWnd,PBM_SETMARQUEE,iif(lMarquee,1,0),0)
   else
      oWnd:DefControl( Self )
      // In this case?
   endif

But I don't remember how do the else case :(

Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 50 guests