ITaskbarList3 Interface for PROGRESS Bar

ITaskbarList3 Interface for PROGRESS Bar

Postby Jimmy » Fri May 26, 2023 9:13 pm

hi,

i notice that PROGRESS from Fivewin will not show "progress" in Icon of Tasklist like my Xbase++ "self made" PROGRESS
Image
i will make a Sample for Fivewin

---

Xbase++ CODE using Qt4Xb Syntax
Code: Select all  Expand view
// iTasklist Interface
//
METHOD DXE_ProgressBar:StartProgressMode()
LOCAL p := 0
LOCAL nRet := 0
LOCAL r,pu,pwb

   IF ::UseiTasklist = .T.
      ::iTask := @user32:RegisterWindowMessageW(L("TaskbarButtonCreated"))
   ELSE
      ::iTask := 0
   ENDIF

   IF ::iTask = 0
      ::pTaskBarlist := 0
   ELSE
      @ole32:CoCreateInstance( UuidFromString(CLSID_TaskbarList),;
                                                               0,;
                                                      CLSCTX_ALL,;
                               UuidFromString(IID_ITaskbarList3),;
                                                              @p )

      IF p <> S_OK
         ::pTaskBarlist := p
         ::nHrInit      := ::TBL1_HrInit()

         IF ::nHrInit <> S_OK
*           Msgbox( FormatErrorMessage( ::nHrInit ), "Error iTasklist" )
            ::pTaskBarlist := 0
         ENDIF

         // "Turning on" progress mode and setting the initial progress value to 0.
         // m_pTaskBarList3->SetProgressState(m_hWnd, TBPF_NORMAL);
         // m_pTaskBarList3->SetProgressValue(m_hWnd, 0, 100);

         IF ::pTaskBarlist <> 0
            nRet := ::TBL3_SetProgressState( ::MainHandle, TBPF_NORMAL )
            nRet := ::TBL3_SetProgressValue( ::MainHandle, ::nValue, ::nMaximum )
         ENDIF

      ENDIF
   ENDIF

RETURN
// ---------------------------------------------------------------------------------

METHOD DXE_ProgressBar:EndProgressMode()
LOCAL nRet

   IF !EMPTY(::pTaskBarlist)
      // m_pTaskBarList3->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
      // m_pTaskBarList3->Release();
      // m_pTaskBarList3 = NULL;

      nRet := ::TBL3_SetProgressState( ::MainHandle, TBPF_NOPROGRESS )
      nRet := ::TBL3_Release()

      IF NIL <> ::nHrInit
         nRet := ::TBL1_Release()
         ::nHrInit := NIL
      ENDIF

      ::pTaskBarlist := 0

      @ole32:CoUninitialize()
   ENDIF

RETURN
// ---------------------------------------------------------------------------------

METHOD DXE_ProgressBar:TBL1_HrInit()

   IF !Empty(::pTaskBarlist)
      ITaskbarList_uuidof()
      // ::pTaskBarlist will be filled in HrInit
      ::nLastError := ITaskbarList_HrInit(::pTaskBarlist)
   ENDIF

RETURN ::nLastError

// ---------------------------------------------------------------------------------

METHOD DXE_ProgressBar:TBL1_Release()
LOCAL bError
LOCAL oError

   IF !EMPTY(::pTaskBarlist)
      bError := ErrorBlock( {|oErr| Break( oErr ) } )
      BEGIN SEQUENCE
         ::nLastError := ITaskbarList_Release(::pTaskBarlist)
      RECOVER USING oError
      ENDSEQUENCE
      ErrorBlock( bError )
   ENDIF

RETURN ::nLastError

// ---------------------------------------------------------------------------------

METHOD DXE_ProgressBar:TBL3_SetProgressState(hwnd, tbpFlags)

   DEFAULT hwnd     TO ::MainHandle,;
           tbpFlags TO TBPF_NORMAL

   IF !Empty(::pTaskBarlist)
      ::nLastError := ITaskbarList3_SetProgressState(::pTaskBarlist, hwnd, tbpFlags )
   ENDIF

RETURN ::nLastError

// ---------------------------------------------------------------------------------

METHOD DXE_ProgressBar:TBL3_SetProgressValue(hwnd, ullCompleted, ullTotal)

   DEFAULT hwnd         TO ::MainHandle,;
           ullCompleted TO ::nValue    ,;
           ullTotal     TO ::nMaximum

   IF !Empty(::pTaskBarlist)
      ::nLastError := ITaskbarList3_SetProgressValue(::pTaskBarlist,hwnd,ullCompleted,ullTotal)
   ENDIF

RETURN ::nLastError

// ---------------------------------------------------------------------------------

METHOD DXE_ProgressBar:TBL3_Release()
LOCAL bError
LOCAL oError

   IF !Empty(::pTaskBarlist)
      bError := ErrorBlock( {|oErr| Break( oErr ) } )
      BEGIN SEQUENCE
         ::nLastError := ITaskbarList3_Release(::pTaskBarlist)
      RECOVER USING oError
      ENDSEQUENCE
      ErrorBlock( bError )
   ENDIF

RETURN ::nLastError
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: ITaskbarList3 Interface for PROGRESS Bar

Postby Antonio Linares » Sat May 27, 2023 10:30 am

Dear Jimmy,

This seems to work fine:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg

   DEFINE DIALOG oDlg

   ACTIVATE DIALOG oDlg CENTER ;
      ON CLICK MsgInfo( Test( oDlg:hWnd ) )

return nil  

#pragma BEGINDUMP

#include <Windows.h>
#include <ObjBase.h>
#include <shobjidl.h>
#include <hbapi.h>

HB_FUNC( TEST )
{
   ITaskbarList3* pTaskbarList;
   HRESULT hr;
   int progress;
   HWND hWnd = ( HWND ) hb_parnl( 1 );

   CoInitialize(NULL);

   hr = CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, (LPVOID*)&pTaskbarList);
   if (FAILED(hr)) {
      MessageBox( 0, "Failed to create ITaskbarList3 instance. Error code: 0x%08X\n", "ok", 0 );
      CoUninitialize();
   }

   hb_retptr( pTaskbarList );
}

#pragma ENDDUMP
regards, saludos

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

Re: ITaskbarList3 Interface for PROGRESS Bar

Postby Antonio Linares » Sat May 27, 2023 11:00 am

Dear Jimmy,

Enhanced version. You can use this code to develop a similar Class:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg

   DEFINE DIALOG oDlg

   ACTIVATE DIALOG oDlg CENTER ;
      ON CLICK MsgInfo( Test( oDlg:hWnd ) )

return nil  

#pragma BEGINDUMP

#include <Windows.h>
#include <ObjBase.h>
#include <shobjidl.h>
#include <hbapi.h>

HB_FUNC( TEST )
{
   ITaskbarList3 * pTaskbarList;
   HWND hWnd = ( HWND ) hb_parnl( 1 );

   CoInitialize(NULL);

   CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, (LPVOID*)&pTaskbarList);
   pTaskbarList->lpVtbl->HrInit( pTaskbarList );
   pTaskbarList->lpVtbl->SetProgressState( pTaskbarList, hWnd, TBPF_NORMAL );
   pTaskbarList->lpVtbl->SetProgressValue( pTaskbarList, hWnd, 0, 100 );

   hb_retptr( pTaskbarList );
}

#pragma ENDDUMP
regards, saludos

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

Re: ITaskbarList3 Interface for PROGRESS Bar

Postby Antonio Linares » Sat May 27, 2023 11:33 am

Starting its implementation. Could you please provide an example of its use ?
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oDxe

   DEFINE DIALOG oDlg

   ACTIVATE DIALOG oDlg CENTER ;
      ON CLICK ( oDxe := DXE_ProgressBar():New(),;
                 oDxe:HrInit(),;
                 oDxe:SetProgressState( oDlg:hWnd ),;
                 oDxe:SetProgressValue( oDlg:hWnd, 0, 100 ),;
                 oDxe:Release() )

return nil  

#define TBPF_NORMAL      2

CLASS DXE_ProgressBar

   DATA   pTaskBarlist
   DATA   MainHandle
   DATA   nLastError
   DATA   nValue
   DATA   nMaximum

   METHOD New()
   METHOD StartProgressMode() VIRTUAL
   METHOD EndProgressMode() VIRTUAL
   METHOD HrInit()
   METHOD Release()
   METHOD SetProgressState( hWnd, tbpFlags )
   METHOD SetProgressValue( hWnd, ullCompleted, ullTotal )
   METHOD TBL3_Release() VIRTUAL

ENDCLASS

METHOD New() CLASS DXE_ProgressBar

   ::nLastError = ITaskbarList_New( @::pTaskBarlist )
   MsgInfo( ::pTaskBarlist )

return Self  

METHOD HrInit() CLASS DXE_ProgressBar

   if ! Empty( ::pTaskBarlist )
      // ITaskbarList_uuidof()
      ::nLastError := ITaskbarList_HrInit( ::pTaskBarlist )
   endif

return ::nLastError

METHOD Release() CLASS DXE_ProgressBar

   local bError, oError

   IF ! Empty( ::pTaskBarlist )
      bError = ErrorBlock( {|oErr| Break( oErr ) } )
      BEGIN SEQUENCE
         ::nLastError := ITaskbarList_Release( ::pTaskBarlist )
      RECOVER USING oError
      ENDSEQUENCE
      ErrorBlock( bError )
   ENDIF

return ::nLastError

METHOD SetProgressState( hWnd, tbpFlags ) CLASS DXE_ProgressBar

   DEFAULT hWnd := ::MainHandle, tbpFlags := TBPF_NORMAL

   if ! Empty( ::pTaskBarlist )
      ::nLastError := ITaskbarList3_SetProgressState( ::pTaskBarlist, hWnd, tbpFlags )
   endif

return ::nLastError

METHOD SetProgressValue( hWnd, ullCompleted, ullTotal ) CLASS DXE_ProgressBar
   
   DEFAULT hWnd := ::MainHandle, ullCompleted := ::nValue, ullTotal := ::nMaximum

   if ! Empty(::pTaskBarlist)
      ::nLastError := ITaskbarList3_SetProgressValue( ::pTaskBarlist, hWnd, ullCompleted, ullTotal )
   endif

return ::nLastError

#pragma BEGINDUMP

#include <Windows.h>
#include <shobjidl.h>
#include <hbapi.h>

HB_FUNC( ITASKBARLIST_NEW )
{
   ITaskbarList3 * pTaskbarList;
   HRESULT hr;

   CoInitialize(NULL);
   hr = CoCreateInstance( &CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, ( LPVOID * ) &pTaskbarList );

   hb_storptr( pTaskbarList, 1 );
   hb_retnl( hr );
}

HB_FUNC( ITASKBARLIST_HRINIT )
{
   ITaskbarList3 * pTaskbarList = ( ITaskbarList3 * ) hb_parptr( 1 );

   hb_retnl( pTaskbarList->lpVtbl->HrInit( pTaskbarList ) );
}  

HB_FUNC( ITASKBARLIST_RELEASE )
{
   ITaskbarList3 * pTaskbarList = ( ITaskbarList3 * ) hb_parptr( 1 );

   hb_retnl( pTaskbarList->lpVtbl->Release( pTaskbarList ) );
}  

HB_FUNC( ITASKBARLIST3_SETPROGRESSSTATE )
{
   ITaskbarList3 * pTaskbarList = ( ITaskbarList3 * ) hb_parptr( 1 );

   hb_retnl( pTaskbarList->lpVtbl->SetProgressState( pTaskbarList, ( HWND ) hb_parnl( 2 ), hb_parnl( 3 ) ) );
}

HB_FUNC( ITASKBARLIST3_SETPROGRESSVALUE )
{  
   ITaskbarList3 * pTaskbarList = ( ITaskbarList3 * ) hb_parptr( 1 );

   hb_retnl( pTaskbarList->lpVtbl->SetProgressValue( pTaskbarList, ( HWND ) hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ) ) );
}

#pragma ENDDUMP

https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist3
regards, saludos

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

Re: ITaskbarList3 Interface for PROGRESS Bar

Postby Jimmy » Sat May 27, 2023 7:44 pm

hi Antonio,

sorry if i have confuse you
those Xbase++ CODE are Part of CLASS ProgressBar and need "msctls_progress32"

so i have to enhance (copy of) CLASS TProgress with these Method
have made 1st. Step and got HB_FUNC() working :D
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: ITaskbarList3 Interface for PROGRESS Bar

Postby Jimmy » Sun May 28, 2023 8:43 pm

hi Antonio,

i got it working so far
Image
only with ITASKBARLIST_RELEASE -> METHOD EndProgressMode() i don´t know "where" to call it as CLASS TProgress have no "Destroy" ?

---

i use a copy of CLASS TProgress and add some CODE
Code: Select all  Expand view
#IFDEF Use_iTasklistBar

you will find all what i did in Source
Code: Select all  Expand view
*+--------------------------------------------------------------------
*+
*+ Source Module => c:\fwh\0\ITASKBAR\ITASKBAR.PRG
*+
*+    Copyright(C) 1983-2023 by Auge & Ohr
*+
*+    Functions: Procedure MAIN()
*+               Procedure DoStep()
*+
*+    Reformatted by Click! 2.05.42 on May-28-2023 at  4:38 am
*+
*+--------------------------------------------------------------------

#include "FiveWin.ch"
#include "Slider.ch"

STATIC cVersion := "0.03"

*+--------------------------------------------------------------------
*+
*+    Procedure MAIN()
*+
*+--------------------------------------------------------------------
*+
PROCEDURE MAIN

LOCAL oMain, oProg, oSlider, oBtn_1, oBtn_2, oBtn_3
LOCAL nVar1

   DEFINE WINDOW oMain FROM 0, 0 TO 200, 800 PIXEL TITLE "FiveWin ITaskbarList3 Interface Demo " + cVersion ICON "A1MAIN" NOMAXIMIZE NOMINIMIZE

      @ 010, 20 PROGRESS oProg POSITION 0 SIZE 750, 30 PIXEL
      oProg:SetRange( 1, 100 )

      @ 050, 10 SLIDER oSlider VAR nVar1 OF oMain ;
              HORIZONTAL ;
              TOP DIRECTION ;
              RANGE 1, 100 ;
              MARKS 10 ;
              SIZE 770, 30 PIXEL ;
              ON CHANGE( DoStep( oMain, oProg, nVar1 ) )

      @ 090, 200 BUTTON oBtn_1 PROMPT FWString( "Error" ) SIZE 80, 60 PIXEL ACTION( oProg:ColorError() ) OF oMain
      @ 090, 350 BUTTON oBtn_2 PROMPT FWString( "Reset" ) SIZE 80, 60 PIXEL ACTION( oProg:Reset(), oProg:SetIcoValue( nVar1, 100 ) ) OF oMain
      @ 090, 500 BUTTON oBtn_3 PROMPT FWString( "Pause" ) SIZE 80, 60 PIXEL ACTION( oProg:ColorPause() ) OF oMain

#IFDEF _HMG_
   END WINDOW
#ENDIF

   ACTIVATE WINDOW oMain ;
           ON INIT( oProg:SetRange( 1, 100 ) ) ;
           CENTER

RETURN

*+--------------------------------------------------------------------
*+
*+    Procedure DoStep()
*+
*+    Called from ( itaskbar.prg )   1 - procedure main()
*+
*+--------------------------------------------------------------------
*+
PROCEDURE DoStep( oMain, oProg, nVar1 )

   oProg:SetPos( nVar1 )
   // set Position in Taskbar Icon of App
   oProg:SetIcoValue( nVar1, 100 )
RETURN

*+ EOF: ITASKBAR.PRG


Code: Select all  Expand view
#pragma BEGINDUMP

#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>
#include <ShlObj.h>

HB_FUNC( ITASKBARLIST_NEW )
{
 ITaskbarList3 * pTaskbarList;
 HRESULT hr;

 CoInitialize  (  NULL  );
 hr = CoCreateInstance  ( &CLSID_TaskbarList,   NULL, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3,   ( LPVOID *   ) &pTaskbarList   );

 hb_storptr  ( pTaskbarList,   1   );
 hb_retnl  ( hr   );
}

HB_FUNC( ITASKBARLIST_HRINIT )
{
 ITaskbarList3 * pTaskbarList =   ( ITaskbarList3 *   ) hb_parptr  (   1   );

 hb_retnl  ( pTaskbarList->lpVtbl->HrInit  ( pTaskbarList   )   );
}

HB_FUNC( ITASKBARLIST_RELEASE )
{
 ITaskbarList3 * pTaskbarList =   ( ITaskbarList3 *   ) hb_parptr  (   1   );

 hb_retnl  ( pTaskbarList->lpVtbl->Release  ( pTaskbarList   )   );
}

HB_FUNC( ITASKBARLIST_SETPROGRESSSTATE )
{
 ITaskbarList3 * pTaskbarList =   ( ITaskbarList3 *   ) hb_parptr  (   1   );

 hb_retnl  ( pTaskbarList->lpVtbl->SetProgressState  ( pTaskbarList,   ( HWND   ) hb_parnl  (   2   ), hb_parnl  (   3   )   )   );
}

HB_FUNC( ITASKBARLIST_SETPROGRESSVALUE )
{
 ITaskbarList3 * pTaskbarList = ( ITaskbarList3 * ) hb_parptr ( 1 );

   #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 2 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 2 );
   #endif
   ULONGLONG n = hb_parnll( 3 );
   ULONGLONG m = hb_parnll( 4 );

 hb_retnl  ( pTaskbarList->lpVtbl->SetProgressValue  ( pTaskbarList, ( HWND ) hWnd, n, m  ) );
}

#pragma ENDDUMP

Code: Select all  Expand view
// Progress Control support

#include "FiveWin.ch"
#include "Constant.ch"

#define COLOR_WINDOW         5
#define COLOR_WINDOWTEXT     8
#define COLOR_BTNFACE       15
#define COLOR_BTNSHADOW     16
#define COLOR_BTNHIGHLIGHT  20

#define PBM_SETRANGE      1025
#define PBM_SETPOS        1026
#define PBM_DELTAPOS      1027
#define PBM_SETSTEP       1028
#define PBM_STEPIT        1029
#define PBM_GETPOS        1032
#define PBM_SETMARQUEE    1034

#define PBS_SMOOTH           1
#define PBS_VERTICAL         4

#ifndef PBS_MARQUEE
#define PBS_MARQUEE             0x08
#endif

#ifdef __XPP__
#define ::Super ::TControl
#define New   _New
#endif

#ifdef __CLIPPER__
#define CTRL_CLASS  "msctls_progress"
#else
#define CTRL_CLASS  "msctls_progress32"
#endif

#DEFINE Use_iTasklistBar         // Jimmy

#DEFINE S_OK                     0
#DEFINE TBPF_NOPROGRESS          0
#DEFINE TBPF_INDETERMINATE       0x1
#DEFINE TBPF_NORMAL              0x2
#DEFINE TBPF_ERROR               0x4
#DEFINE TBPF_PAUSED              0x8
#Define PBST_NORMAL              0x0001
#DEFINE PBST_ERROR               0x0002
#DEFINE PBST_PAUSED              0x0003
#DEFINE PBM_GETSTATE             (WM_USER+17)
#DEFINE PBM_SETSTATE             (WM_USER+16)

#xtranslate ITaskbarList_uuidof()   => UuidFromString("56FDF342-FD6D-11d0-958A-006097C9A090")
#xtranslate ITaskbarList2_uuidof()  => UuidFromString("602D4995-B13A-429b-A66E-1935E44F4317")
#xtranslate ITaskbarList3_uuidof()  => UuidFromString("EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF")
#xtranslate ITaskbarList4_uuidof()  => UuidFromString("C43DC798-95D1-4BEA-9030-BB99E2983A1A")

*+--------------------------------------------------------------------
*+
*+    Class TProgress
*+
*+--------------------------------------------------------------------
*+
CLASS TProgress FROM TControl

   DATA nMin, nMax, nPos, nStep AS NUMERIC

   METHOD New( nTop, nLeft, oWnd, nPos, nClrFore, ;
               nClrBack, lPixel, lDesign, nWidth, nHeight, ;
               cMsg, lVertical ) CONSTRUCTOR

   METHOD ReDefine( nId, oWnd ) CONSTRUCTOR

   METHOD cToChar() INLINE ::Super:cToChar( CTRL_CLASS )

   METHOD DEFAULT()

   METHOD DeltaPos( nIncrement ) INLINE ;
                    SendMessage( ::hWnd, PBM_DELTAPOS, nIncrement )

   METHOD HandleEvent( nMsg, nWParam, nLParam )

   METHOD Initiate( hDlg )

   MESSAGE SETPOS( nPos ) METHOD _SetPos( nPos )

   METHOD SetMarquee( lOnOff )

   METHOD GETPOS()

   METHOD SetRange( nMin, nMax ) INLINE ;
                    SendMessage( ::hWnd, PBM_SETRANGE, 0, nMakeLong( nMin, nMax ) ), ;
                    ::nMin := nMin, ::nMax := nMax

#ifndef __XPP__
   MESSAGE _nPosition( nPos ) METHOD _SetPos( nPos )

   MESSAGE nPosition METHOD GETPOS()
#else
   METHOD nPosition() INLINE ::GetPos()
#endif

   METHOD SetStep( nStepInc ) INLINE ;
                   SendMessage( ::hWnd, PBM_SETSTEP, ::nStep := nStepInc )

   METHOD StepIt() INLINE SendMessage( ::hWnd, PBM_STEPIT ), ::nPos += ::nStep

#IFDEF Use_iTasklistBar
   // iTasklist Interface
   //
   DATA pTaskBarlist                                                  // Handle iTasklist Interface
   DATA nHrInit                                                       // Flag S_OK

   METHOD StartProgressMode()
   METHOD EndProgressMode()
   METHOD SetIcoValue( nVar, nMaximum )
   METHOD ColorError()
   METHOD ColorPause()
   METHOD Reset()
   METHOD SetState( nState )
#ENDIF

ENDCLASS

METHOD New( nTop, nLeft, oWnd, nPos, nClrFore, nClrBack, lPixel, ;
               lDesign, nWidth, nHeight, cMsg, lVertical, lMarquee ) CLASS TProgress

   DEFAULT nTop := 0, nLeft := 0, ;
           oWnd := GetWndDefault(), ;
           nClrFore := oWnd:nClrText, ;
           nClrBack := GetSysColor( COLOR_BTNFACE ), ;
           lPixel := .f., ;
           lDesign := .f., ;
           nWidth := 200, nHeight := 21, ;
           nPos := 0, lVertical := .f., ;
           lMarquee := .F.

#ifdef __XPP__
#undef New
#endif

   ::nStyle = nOR( WS_CHILD, WS_VISIBLE, ;
                   IF( lDesign, WS_CLIPSIBLINGS, 0 ), ;
                   IF( lVertical, PBS_VERTICAL, 0 ), WS_TABSTOP, ;
                   IF( lMarquee, PBS_MARQUEE, 0 ) )
   ::nId = ::GetNewId()
   ::oWnd = oWnd
   ::cMsg = cMsg
   ::nTop = IF( lPixel, nTop, nTop * SAY_CHARPIX_H )
   ::nLeft = IF( lPixel, nLeft, nLeft * SAY_CHARPIX_W )
   ::nBottom = ::nTop + nHeight - 1
   ::nRight = ::nLeft + nWidth - 1
   ::lDrag = lDesign
   ::lCaptured = .f.
   ::nClrText = nClrFore
   ::nClrPane = nClrBack
   ::nPos = nPos
   ::nMax = 100

   IF !EMPTY( oWnd:hWnd )
      ::Create( CTRL_CLASS )
      oWnd:AddControl( Self )
      SendMessage( ::hWnd, PBM_SETMARQUEE, IF( lMarquee, 1, 0 ), 0 )
   ELSE
      oWnd:DefControl( Self )
   ENDIF

   ::Default()

   IF lDesign
      ::CheckDots()
   ENDIF

#IFDEF Use_iTasklistBar
   ::StartProgressMode()
#ENDIF

RETURN Self

METHOD ReDefine( nId, oWnd ) CLASS TProgress

   DEFAULT oWnd := GetWndDefault()

   ::nId = nId
   ::oWnd = oWnd

   oWnd:DefControl( Self )

#IFDEF Use_iTasklistBar
   ::StartProgressMode()
#ENDIF

RETURN Self

METHOD _SetPos( nPos ) CLASS TProgress

   SendMessage( ::hWnd, PBM_SETPOS, nPos )
   ::nPos := nPos

RETURN nil

METHOD GETPOS() CLASS TProgress

RETURN ::nPos

METHOD DEFAULT() CLASS TProgress

   // ::SetRange( 0, 10 )
   ::nPosition = ::nPos

RETURN nil

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TProgress

   IF nMsg == WM_TIMER
      RETURN nil
   ENDIF

RETURN ::Super:HandleEvent( nMsg, nWParam, nLParam )

METHOD Initiate( hDlg ) CLASS TProgress

   ::Super:Initiate( hDlg )
   SendMessage( ::hWnd, PBM_SETMARQUEE, IF( ::WinStyle( PBS_MARQUEE ), 1, 0 ), 0 )

RETURN nil

METHOD SetMarquee( lOnOff ) CLASS TProgress

   ::WinStyle( PBS_MARQUEE, lOnOff )
   SendMessage( ::hWnd, PBM_SETMARQUEE, IF( lOnOff, 1, 0 ), 0 )

RETURN nil

   //----------------------------------------------------------------------------//

#IFDEF Use_iTasklistBar

METHOD StartProgressMode() CLASS TProgress
LOCAL nRet, nLastError

   nLastError := ITaskbarList_New( @::pTaskBarlist )

   IF nLastError <> S_OK
      MsgInfo( ::pTaskBarlist )
   ELSE

      IF !EMPTY( ::pTaskBarlist )
         //  how to use
         //  ITaskbarList_uuidof()

         ::nHrInit := ITaskbarList_HrInit( ::pTaskBarlist )
      ENDIF

      IF ::nHrInit <> S_OK
         MsgInfo( "Error iTasklist" )
         ::pTaskBarlist := 0
      ENDIF

      IF !EMPTY( ::pTaskBarlist )
         // "Turning on" progress mode and setting the initial progress value to 0.
         nRet := ITaskbarList_SetProgressState( ::pTaskBarlist, ::oWnd:hwnd, TBPF_NORMAL )
         nRet := ITaskbarList_SetProgressValue( ::pTaskBarlist, ::oWnd:hwnd, ::nPos, ::nMax )
      ENDIF

   ENDIF

RETURN Self

METHOD EndProgressMode() CLASS TProgress
LOCAL nRet

   IF !EMPTY( ::pTaskBarlist )
      nRet := ITaskbarList_SetProgressState( ::pTaskBarlist, ::oWnd:hwnd, TBPF_NOPROGRESS )
      //    nRet := ITaskbarList3_Release(::pTaskBarlist)
   ENDIF

   IF NIL <> ::nHrInit
      IF !EMPTY( ::pTaskBarlist )
         nRet := ITaskbarList_Release( ::pTaskBarlist )
      ENDIF
      ::nHrInit := NIL
   ENDIF

   ::pTaskBarlist := 0

   //  hm ...
   //  @ole32:CoUninitialize()

RETURN Self

METHOD SetIcoValue( nVar, nMaximum ) CLASS TProgress
   DEFAULT nVar := 0
   DEFAULT nMaximum := 100
   ITaskbarList_SetProgressValue( ::pTaskBarlist, ::oWnd:hwnd, nVar, nMaximum )
RETURN Self

METHOD ColorError() CLASS TProgress
   ITaskbarList_SetProgressState( ::pTaskBarlist, ::oWnd:hwnd, TBPF_ERROR )
   ::SetState( PBST_ERROR )
RETURN Self

METHOD ColorPause() CLASS TProgress
   ITaskbarList_SetProgressState( ::pTaskBarlist, ::oWnd:hwnd, TBPF_PAUSED )
   ::SetState( PBST_PAUSED )
RETURN Self

METHOD Reset() CLASS TProgress
   ITaskbarList_SetProgressState( ::pTaskBarlist, ::oWnd:hwnd, TBPF_NOPROGRESS )
   ::SetState( PBST_NORMAL )
RETURN Self

METHOD SetState( nState ) CLASS TProgress
   PostMessage( ::hwnd, PBM_SETSTATE, nState, 0 )
RETURN Self

#ENDIF

*+ EOF: TPROGRES.PRG


32 Bit BCC7 *.MAK
Code: Select all  Expand view
HBDIR=c:\harbour
BCDIR=c:\BCC7
FWDIR=c:\fwh

#change these paths as needed
.path.OBJ = .\obj
.path.PRG = .\
.path.CH  = $(FWDIR)\include;$(HBDIR)\include;$(BCDIR)\include\windows
.path.C   = .\
.path.rc  = .\

#important: Use Uppercase for filenames extensions, in the next two rules!

PRG = \
ITASKBAR.PRG \
TPROGRES.PRG \
HB_FUNC.PRG

PROJECT    : ITASKBAR.EXE

ITASKBAR.exe  : $(PRG:.PRG=.OBJ) ITASKBAR.res
   @echo off
   echo $(BCDIR)\lib\c0w32.obj + > b32.bc
   echo obj\ITASKBAR.obj obj\TPROGRES.obj obj\HB_FUNC.obj , + >> b32.bc
   echo ITASKBAR.exe, + >> b32.bc
   echo ITASKBAR.map, + >> b32.bc
   echo $(FWDIR)\lib\FiveH.lib $(FWDIR)\lib\FiveHC.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbrtl.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbvmmt.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\gtgui.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hblang.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbmacro.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbrdd.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\rddntx.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\rddcdx.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\rddfpt.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbsix.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbdebug.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbcommon.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbpp.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbwin.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbcpage.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbct.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbpcre.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbcplr.lib + >> b32.bc
   echo $(HBDIR)\lib\win\bcc\xhb.lib + >> b32.bc

   echo $(HBDIR)\lib\win\bcc\hbziparc.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbmzip.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbzlib.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\minizip.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\png.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbusrrdd.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbtip.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbzebra.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbcurl.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\libcurl.lib +  >> b32.bc
   echo $(HBDIR)\lib\win\bcc\hbxpp.lib +  >> b32.bc

   echo $(FWDIR)\lib\dolphin.lib +  >> b32.bc

   echo $(BCDIR)\lib\cw32mt.lib + >> b32.bc
   echo $(BCDIR)\lib\uuid.lib + >> b32.bc
   echo $(BCDIR)\lib\ws2_32.lib +  >> b32.bc
   echo $(BCDIR)\lib\psdk\gdiplus.lib +  >> b32.bc
   echo $(BCDIR)\lib\import32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\odbc32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\nddeapi.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\iphlpapi.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\msimg32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\psapi.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\rasapi32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\shell32.lib,  >> b32.bc

   IF EXIST ITASKBAR.res echo ITASKBAR.res >> b32.bc
   $(BCDIR)\bin\ilink32 -Gn -aa -Tpe -s @b32.bc
   del b32.bc

.PRG.OBJ:
  $(HBDIR)\bin\harbour $< /N /W /Oobj\ /I$(FWDIR)\include;$(HBDIR)\include;$(BCDIR)\include\windows

  $(BCDIR)\bin\bcc32 -c -tWM -I$(HBDIR)\include -oobj\$& obj\$&.c

.C.OBJ:
  echo -c -tWM -D__HARBOUR__ -DHB_API_MACROS > tmp
  echo -I$(HBDIR)\include;$(FWDIR)\include >> tmp
  $(BCDIR)\bin\bcc32 -oobj\$& @tmp $&.c
  del tmp

ITASKBAR.res : ITASKBAR.rc
  $(BCDIR)\bin\brc32.exe -r ITASKBAR.rc


64 Bit MSVC *.HBP
Code: Select all  Expand view
-gui -mt
-Ic:\fwh64\include
ITASKBAR.PRG
tprogres.prg
HB_FUNC.PRG
-Lc:\fwh64\lib
-lFiveH64
-lFiveHC64
-lgdiplus
-lole32
-lOleDlg
-lversion
xhb.hbc
hbct.hbc
hbwin.hbc
hbmzip.hbc
hbziparc.hbc
hbfoxpro.hbc
-ldflag=/NODEFAULTLIB:msvcrt
ITASKBAR.rc

! Note : NEED Mainfest
Code: Select all  Expand view
1 24 "Windows10.Manifest"

1 VERSIONINFO
FILEVERSION 0,0,1,3
PRODUCTVERSION 1,0,0,0
 FILEFLAGS 0x00000001
 FILEFLAGSMASK 0x0000003F
 FILEOS 0x00040000
 FILETYPE 0x1
 FILESUBTYPE 0x040
    BEGIN
        BLOCK "StringFileInfo"
        BEGIN
            BLOCK "040904b0"
            BEGIN
             VALUE "FileDescription", "FiveWin ITaskbarList3 Interface Demo\000"
             VALUE "FileVersion", "0.6.9.0\000"
             VALUE "InternalName", "DUALGRID\000"
         VALUE "LegalCopyright", "Copyright 1983-2023 Yiu-Software\000"
             VALUE "LegalTrademarks", "Harbour\000"
             VALUE "OriginalFilename", "DUALGRID.EXE\000"
             VALUE "CompanyName", "Yiu-Software\000"
             VALUE "ProductName", "DUALGRID\000"
             VALUE "ProductVersion", "1.0.0.0\000"
             VALUE "Comments", "Created by Auge & Ohr\000"
            END
        END
        BLOCK "VarFileInfo"
        BEGIN
            VALUE "Translation",  0x0407, 1252
        END
    END
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: ITaskbarList3 Interface for PROGRESS Bar

Postby Antonio Linares » Mon May 29, 2023 11:03 am

very good :-)

Many thanks for sharing it
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 110 guests

cron