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
Just a bump on this in case anyone has done this by now.
#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 ENDDUMPAntonino,
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)
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. ![]()
Regards,
Antonino
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 *
It seems to me as you are using C++ mode, not C mode.
hbmk2 taskBarList.prg -gui -i..\include -L..\lib -lFiveH32 -lFiveHC32 xhb.hbc -ldflag=Version.lib -ldflag=oledlg.lib -ldflag=gdiplus.lib -ldflag=/NODEFAULTLIB:libcmt#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
You really hate me! windows 10!!
![]()
![]()
![]()
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
AntoninoP wrote:You really hate me! windows 10!!
![]()
![]()
BTW, Windows 10 10122 is much more stable! ![]()
A very good news
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