Windows 7 taskbar button progress bar

Windows 7 taskbar button progress bar

Postby AlexSchaft » Mon Nov 14, 2011 6:07 am

Hi,

I'm trying to show progress on the windows taskbar via the api from http://msdn.microsoft.com/en-us/library/windows/desktop/dd391698%28v=vs.85%29.aspx but can't seem to get it to work.

Has anyone else done this?

Alex
User avatar
AlexSchaft
 
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Re: Windows 7 taskbar button progress bar

Postby AlexSchaft » Thu May 24, 2012 9:19 am

Just a bump on this in case anyone has done this by now.
User avatar
AlexSchaft
 
Posts: 172
Joined: Fri Oct 07, 2005 1:29 pm
Location: Edenvale, Gauteng, South Africa

Re: Windows 7 taskbar button progress bar

Postby AntoninoP » Thu May 28, 2015 7:53 am

Hello,
I resurrect this thread to share a FiveWin support for progress bar in task bar:

Code: Select all  Expand view  RUN
#include <fivewin.ch>
#include <slider.ch>

function main()
   LOCAL oDlg, oBru, nSlider := 40
   DEFINE WINDOW oDlg FROM  0,0 TO 500,400 PIXEL TITLE "Test" BRUSH oBru
   
   @   8,8 BUTTON "RESET"      SIZE 80,36 PIXEL ACTION TBL_RESET(oDlg:hWnd)
   @  48,8 BUTTON "PROCESSING" SIZE 80,36 PIXEL ACTION TBL_PROCESSING(oDlg:hWnd)
   @  88,8 BUTTON "PROGRESS"   SIZE 80,36 PIXEL ACTION (TBL_SETPROGRESS(oDlg:hWnd), TBL_SETVALUE(oDlg:hWnd, nSlider, 100))
   @ 128,8 BUTTON "ERROR"      SIZE 80,36 PIXEL ACTION TBL_SETERROR(oDlg:hWnd)
   @ 168,8 BUTTON "PAUSE"      SIZE 80,36 PIXEL ACTION TBL_SETPAUSE(oDlg:hWnd)
   
   @ 208,8 SLIDER nSlider HORIZONTAL RANGE 0, 100 SIZE 380,36 PIXEL ON THUMBPOS TBL_SETVALUE(oDlg:hWnd, nVar, 100)
   
   ACTIVATE WINDOW oDlg
   
return nil

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

ITaskbarList3* TBL_SetProgressState(HWND hWnd, TBPFLAG state)
{
   ITaskbarList3* m_pTaskBarlist;
   HRESULT hr;
   if((hr = CoCreateInstance( &CLSID_TaskbarList, 0, CLSCTX_ALL, &IID_ITaskbarList3, ( void ** ) &m_pTaskBarlist ) )==S_OK)
   {
      if (state != -1)
         m_pTaskBarlist->lpVtbl->SetProgressState( m_pTaskBarlist, hWnd, state );
      return m_pTaskBarlist;
   }
   return NULL;
}

 #ifndef _WIN64
   #define GETHWND ( HWND ) hb_parnl( 1 )
#else
   #define GETHWND ( HWND ) hb_parnll( 1 )
#endif

HB_FUNC( TBL_RESET ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_NOPROGRESS); }

HB_FUNC( TBL_PROCESSING ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_INDETERMINATE); }

HB_FUNC( TBL_SETPROGRESS ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_NORMAL); }

HB_FUNC( TBL_SETVALUE ) //  hWnd, n, max
{
   HWND hWnd = GETHWND;
   ULONGLONG n = hb_parnll(2);
   ULONGLONG m = hb_parnll(3);
   ITaskbarList3* m_pTaskBarlist = TBL_SetProgressState(GETHWND,-1);
   if( m_pTaskBarlist )
   {
      m_pTaskBarlist->lpVtbl->SetProgressValue( m_pTaskBarlist, hWnd, n, m );
   }
}

HB_FUNC( TBL_SETERROR ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_ERROR); }

HB_FUNC( TBL_SETPAUSE ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_PAUSED); }

#pragma ENDDUMP


Here a test program with C code for slider support, I compiled it with Harbour 3.2, FWH 15.03 and Visual Studio compiler.

Maybe It can be include in the next FiveWin release :wink:
Regards,
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 8:23 am

Antonino,

Many thanks! :-)

I am testing it with Borland and I get this error:

Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
antonino.c:
Error E2141 test.prg 25: Declaration syntax error

We need to make this line Borland 5.82 compatible:

ITaskbarList3* TBL_SetProgressState(HWND hWnd, TBPFLAG state)
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby AntoninoP » Thu May 28, 2015 8:41 am

Hello,
Sorry, I don't have Borland C++, and googling it I don't know how get it.
Anyway, It looks like a Windows Kit version issue, I am using the version 8.1 .

Usual disclaimer (from GPL)
This code is provide "as is" without warranty of any kind. The entire risk as to the quality and performance of the program is with you. :D

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

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 2:29 pm

Antonino,

If I try to build it using FWH\samples\buildh32.bat I get these errors:

Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

antonino.c
antonino.prg(29) : error C2664: 'HRESULT CoCreateInstance(const IID &,LPUNKNOWN,DWORD,const IID &,LPVOID *)' : cannot convert
argument 1 from 'const CLSID *' to 'const IID &'
Reason: cannot convert from 'const CLSID *' to 'const IID'
No constructor could take the source type, or constructor overload resolution was ambiguous
antonino.prg(32) : error C2039: 'lpVtbl' : is not a member of 'ITaskbarList3'
C:\Program Files (x86)\Windows Kits\8.1\include\um\ShObjIdl.h(17308) : see declaration of 'ITaskbarList3'
antonino.prg(32) : error C2227: left of '->SetProgressState' must point to class/struct/union/generic type
antonino.prg(58) : error C2664: 'ITaskbarList3 *TBL_SetProgressState(HWND,TBPFLAG)' : cannot convert argument 2 from 'int' to
'TBPFLAG'
Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
antonino.prg(61) : error C2039: 'lpVtbl' : is not a member of 'ITaskbarList3'
C:\Program Files (x86)\Windows Kits\8.1\include\um\ShObjIdl.h(17308) : see declaration of 'ITaskbarList3'
antonino.prg(61) : error C2227: left of '->SetProgressValue' must point to class/struct/union/generic type
LINK : fatal error LNK1181: cannot open input file 'antonino.obj'
* Linking errors *
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 2:30 pm

It seems to me as you are using C++ mode, not C mode.
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby AntoninoP » Thu May 28, 2015 2:49 pm

Hello,
You are using the C++ style, if you look in ShObjIdl.h at line 17366, you can see: above the C++ interface, with method inside the structure, and below the C interface with a structure of pointers at functions that take as first parameter the pointer of interface.
Anyway:
C++:
m_pTaskBarlist->SetProgressState( hWnd, state );
C:
m_pTaskBarlist->lpVtbl->SetProgressState( m_pTaskBarlist, hWnd, state );

I compile with this command:
Code: Select all  Expand view  RUN
hbmk2 taskBarList.prg -gui -i..\include -L..\lib -lFiveH32 -lFiveHC32 xhb.hbc -ldflag=Version.lib -ldflag=oledlg.lib -ldflag=gdiplus.lib -ldflag=/NODEFAULTLIB:libcmt

from the fivewin samples directory.

Here a version that compile in both mode:
Code: Select all  Expand view  RUN
#include <fivewin.ch>
#include <slider.ch>

function main()
   LOCAL oDlg, oBru, nSlider := 40
   DEFINE WINDOW oDlg FROM  0,0 TO 500,400 PIXEL TITLE "TaskBarList" BRUSH oBru
   
   @   8,8 BUTTON "RESET"      SIZE 80,36 PIXEL ACTION TBL_RESET(oDlg:hWnd)
   @  48,8 BUTTON "PROCESSING" SIZE 80,36 PIXEL ACTION TBL_PROCESSING(oDlg:hWnd)
   @  88,8 BUTTON "PROGRESS"   SIZE 80,36 PIXEL ACTION (TBL_SETPROGRESS(oDlg:hWnd), TBL_SETVALUE(oDlg:hWnd, nSlider, 100))
   @ 128,8 BUTTON "ERROR"      SIZE 80,36 PIXEL ACTION TBL_SETERROR(oDlg:hWnd)
   @ 168,8 BUTTON "PAUSE"      SIZE 80,36 PIXEL ACTION TBL_SETPAUSE(oDlg:hWnd)
   
   @ 208,8 SLIDER nSlider HORIZONTAL RANGE 0, 100 SIZE 380,36 PIXEL ON THUMBPOS TBL_SETVALUE(oDlg:hWnd, nVar, 100)
   
   ACTIVATE WINDOW oDlg
   
return nil

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

ITaskbarList3* TBL_SetProgressState(HWND hWnd, TBPFLAG state)
{
   ITaskbarList3* m_pTaskBarlist;
   HRESULT hr;
#if defined(__cplusplus)
   if((hr = CoCreateInstance( CLSID_TaskbarList, 0, CLSCTX_ALL, IID_ITaskbarList3, ( void ** ) &m_pTaskBarlist ) )==S_OK)
#else
   if((hr = CoCreateInstance( &CLSID_TaskbarList, 0, CLSCTX_ALL, &IID_ITaskbarList3, ( void ** ) &m_pTaskBarlist ) )==S_OK)
#endif
   {
      if (state != -1)
#if defined(__cplusplus) && !defined(CINTERFACE)
         m_pTaskBarlist->SetProgressState( hWnd, state );
#else
         m_pTaskBarlist->lpVtbl->SetProgressState( m_pTaskBarlist, hWnd, state );
#endif
      return m_pTaskBarlist;
   }
   return NULL;
}

 #ifndef _WIN64
   #define GETHWND ( HWND ) hb_parnl( 1 )
#else
   #define GETHWND ( HWND ) hb_parnll( 1 )
#endif

HB_FUNC( TBL_RESET ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_NOPROGRESS); }

HB_FUNC( TBL_PROCESSING ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_INDETERMINATE); }

HB_FUNC( TBL_SETPROGRESS ) //  hWnd, n, max
{ TBL_SetProgressState(GETHWND,TBPF_NORMAL); }

HB_FUNC( TBL_SETVALUE )
{
   HWND hWnd = GETHWND;
   ULONGLONG n = hb_parnll(2);
   ULONGLONG m = hb_parnll(3);
   ITaskbarList3* m_pTaskBarlist = TBL_SetProgressState(GETHWND,(TBPFLAG)-1);
   if( m_pTaskBarlist )
   {
#if defined(__cplusplus) && !defined(CINTERFACE)
      m_pTaskBarlist->SetProgressValue( hWnd, n, m );
#else
      m_pTaskBarlist->lpVtbl->SetProgressValue( m_pTaskBarlist, hWnd, n, m );
#endif
   }
}

HB_FUNC( TBL_SETERROR ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_ERROR); }

HB_FUNC( TBL_SETPAUSE ) //  hWnd
{ TBL_SetProgressState(GETHWND,TBPF_PAUSED); }

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

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 3:06 pm

I was able to build it removing /TP flag

I have tested it in Windows 10 and it seems not to work:
Image

I click on the buttons and no action is done

going to digg some more :-)
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby AntoninoP » Thu May 28, 2015 3:13 pm

You really hate me! windows 10!!
:lol: :lol: :lol:
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 3:16 pm

Antonino,

This control what is supposed to do ? I don't understand what it is for.

I have seen that it is only available from Windows 7 on
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 3:24 pm

Ok, I found what it does. The color progress bar shown in the taskbar app icon :-)

I have tested it a few times on Windows 10 and just worked once.

Could other users test this EXE on XP, 7 and 8 ?

https://bitbucket.org/fivetech/fivewin-contributions/downloads/taskbarlist.exe

Thanks for the feedback
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 3:26 pm

Antonino,

AntoninoP wrote:You really hate me! windows 10!!
:lol: :lol: :lol:


I use to test Windows betas before they are publically available to check in advance if Harbour/FWH properly work on them :-)
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby Antonio Linares » Thu May 28, 2015 3:27 pm

BTW, Windows 10 10122 is much more stable! :-)

A very good news
regards, saludos

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

Re: Windows 7 taskbar button progress bar

Postby AntoninoP » Thu May 28, 2015 3:35 pm

Antonio Linares wrote:Ok, I found what it does. The color progress bar shown in the taskbar app icon :-)

I have tested it a few times on Windows 10 and just worked once.

Could other users test this EXE on XP, 7 and 8 ?

https://bitbucket.org/fivetech/fivewin-contributions/downloads/taskbarlist.exe

Thanks for the feedback

I am using windows 7 and It should works fine on Windows 8
On XP it should fails to create the Interface and manage it.
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: cmsoft and 39 guests