ENVI^ ForceLocal=1
ENVI$  &&NL=0D 0A
WIN1

_SUB WIN1,W730H419,任务栏进度条演示,    
    SET &TasbarReady=0
    ENVI @this.MSG=%&WM_TASKBARBUTTONCREATED%: SET TasbarReady=1
    TIME -t:1 T1,0,TEST1
    ITEM -na Button3,L157T28W79H32,资源管理器,,#3,0x10   //提供图标
    ENVI @Button3.ID=?;;&&gid
_END

_SUB TEST1
    SET I=5000
    LOOP #[ %I%>0 & %TasbarReady%=0 ], TEAM CALC I=%I%-50| WAIT 50
    TaskBarPer   %__WinID%  ICON  %gid% "Test"
    TEAM TaskBarPer %__WinID%  40 100|  WAIT 1000
    TEAM TaskBarPer %__WinID%  80  100| WAIT 1000
    TEAM TaskBarPer %__WinID%  100 100| WAIT 2000
    TEAM TaskBarPer %__WinID% 0
_END

_SUB TEST2
WAIT 100
    //CALL $--ret:&&hm --qw:#  Kernel32.dll,GetModuleHandleW,0
    //CALL $--ret:&&hico --qw:##  User32.dll,LoadIcon,%hm%,3
    //MESS [%&hico%] [%&hm%]  gid[%gid%]
    TaskBarPer   %__WinID%  50 100
    TaskBarPer   %__WinID%  ICON  %gid% "Test"
_END



_SUB TaskBarPer  // %__WinID%  进度数  总数
  SET$ pTaskBarlist3=*8 0
  SET &CLSCTX_INPROC_SERVER=0x1
  SET#$ &CLSID_TaskbarList=44 f3 fd 56   6d fd   d0 11   95 8a  00 60 97 c9 a0 90  //CLSID_TaskbarList={56fdf344-fd6d-11d0-958a-006097c9a090}
  SET#$ &IID_ITaskbarList3=91 FB 1A EA   28 9E   86 4B   90 E9  9E 9F 8A 5E EF AF  //IID_ITaskbarList3={EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}

  lock .ole
  CALL $--ret:* --qd --16  OLE32.DLL,CoCreateInstance,&&hr,*CLSID_TaskbarList,#0,#%CLSCTX_INPROC_SERVER%,*IID_ITaskbarList3,*pTaskBarlist3
  IFEX  #[ 0<>%&hr% ], EXIT
  ^SET &HrInit=3
  ^SET &SetProgressValue=9  //函数序号
  ^SET &SetProgressState=10
  ^SET &SetOverlayIcon=18
  CALL $--ret:&&rs  #,*&pTaskBarlist3.%HrInit%
  {
  FIND $ICON=%~2, TEAM ^CALL $--ret:&&rs --qd:##$  #,*&pTaskBarlist3.%SetOverlayIcon%,%~1,%~3,%~4| EXIT -
  IFEX #[ 0<=%~2 & %~2<=0xF & ''='%~3' ], ^CALL $--ret:&&rs --qd#  #,*&pTaskBarlist3.%SetProgressState%,%~1,%~2
  IFEX #[ 0<=%~2 & 0<%~3 ],!! ^CALL $--ret:&&ri --qd:#<<  #,*&pTaskBarlist3.%SetProgressValue%,%~1,%~2,%~3
  }
  CALL $--ret:&&ri #,*&pTaskBarlist3.2  //2:Realease() 释放COM
_END

EXIT FILE
_ENDFILE

//TaskBarPer   WinID  ICON 图标句柄 "文本"   //图标
//TaskBarPer   WinID  进度数  总数
//TaskBarPer   WinID  0   //取消
//TaskBarPer   WinID  1   //滚动
//TaskBarPer   WinID  2   //正常颜色
//TaskBarPer   WinID  4   //红色
//TaskBarPer   WinID  8   //暂停

 
//SetProgressState 方法设置进度条的状态，实际反映出来就是进度条的颜色，它接受一个窗口句柄和一个状态标记为参数。其中 TBPF_NOPROGRESS(0) 为取消进度条， TBPF_INDETERMINATE(1) 是一个不断滚动的，无确定值的进度条。
//SetProgressValue 方法设置进度条的值，也就是当前进度。它的参数是窗口句柄、当前值(UINT64)和总值(UINT64)。如果用这个方法设置了进度条，之前设置的TBPF_INDETERMINATE 将无效。

IFEX #0=1,
{
    struct ITaskbarList3  // ITaskbarList2  ITaskbarList
    {
    //ITaskbarList:
        __virtual HRESULT STDMETHODCALLTYPE QueryInterface( ITaskbarList * This, REFIID riid,void **ppvObject);
        __virtual ULONG   STDMETHODCALLTYPE AddRef( ITaskbarList * This);
        __virtual ULONG   STDMETHODCALLTYPE Release( ITaskbarList * This); /*2:*/
        __virtual HRESULT STDMETHODCALLTYPE HrInit(ITaskbarList * This); /*3:*/
        __virtual HRESULT STDMETHODCALLTYPE AddTab(ITaskbarList * This,  /* [in] */ HWND hwnd);
        __virtual HRESULT STDMETHODCALLTYPE DeleteTab( ITaskbarList * This, /* [in] */ HWND hwnd);
        __virtual HRESULT STDMETHODCALLTYPE ActivateTab( ITaskbarList * This,  /* [in] */ HWND hwnd);
        __virtual HRESULT STDMETHODCALLTYPE SetActiveAlt( ITaskbarList * This, /* [in] */ HWND hwnd);

    //ITaskbarList2:
        __virtual HRESULT STDMETHODCALLTYPE MarkFullscreenWindow( ITaskbarList2 * This, /* [in] */ HWND hwnd, /* [in] */ BOOL fFullscreen);

    //ITaskbarList3
        __virtual int   STDMETHODCALLTYPE SetProgressValue(ITaskbarList3* This,HWND hWnd, ULONGLONG Completed, ULONGLONG Total);/*9:*/
        __virtual int   STDMETHODCALLTYPE SetProgressState(ITaskbarList3* This,HWND hWnd, UINT Flags);/*10:*/
        __virtual void	STDMETHODCALLTYPE RegisterTab(ITaskbarList3* This,HWND hWndTab, HWND hWndMDI);  /*11:*/
        __virtual void	STDMETHODCALLTYPE UnregisterTab(ITaskbarList3* This,HWND hWndTab);
        __virtual void	STDMETHODCALLTYPE SetTabOrder(ITaskbarList3* This,HWND hWndTab, HWND hwndInsertBefore);
        __virtual void	STDMETHODCALLTYPE SetTabActive(ITaskbarList3* This,HWND hWndTab, HWND hWndMDI, INT_PTR dwReserved);/*14:*/
        __virtual void	STDMETHODCALLTYPE ThumbBarAddButtons(ITaskbarList3* This,HWND hWnd, INT_PTR cButtons, struct THUMBBUTTON* pButtons);
        __virtual void	STDMETHODCALLTYPE ThumbBarUpdateButtons(ITaskbarList3* This,HWND hWnd, INT_PTR cButtons, struct THUMBBUTTON* pButtons);
        __virtual void	STDMETHODCALLTYPE ThumbBarSetImageList(ITaskbarList3* This,HWND hWnd, HIMAGELIST himl);
        __virtual void	STDMETHODCALLTYPE SetOverlayIcon(ITaskbarList3* This,HWND hWnd, HICON hIcon, PCWSTR pszDescription) ;
        __virtual void	STDMETHODCALLTYPE SetThumbnailTooltip(ITaskbarList3* This,HWND hWnd, PCWSTR pszTip);
        __virtual void	STDMETHODCALLTYPE SetThumbnailClip(ITaskbarList3* This,HWND hWnd, PRECT prcClip);
    };


}
