ProgressBar на окне TaskBar
Пример того как можно создать progressbar на окне TaskBar. Делается это с помощью подключения соответствующего COM интерфейса. Для примера используется библиотека Window9.
Платформа: Windows
Адаптация примера на FreeBasic: Станислав Будинов
#INCLUDE "window9.bi" 'Enum TBPFLAG 'TBPF_NOPROGRESS = 0 'TBPF_INDETERMINATE = 1 'TBPF_NORMAL = 2 'TBPF_ERROR = 4 'TBPF_PAUSED = 8 'End Enum 'Enum THUMBBUTTONMASK 'THB_BITMAP = 1 'THB_ICON = 2 'THB_TOOLTIP = 4 'THB_FLAGS = 8 'End Enum 'Enum THUMBBUTTONFLAGS 'THBF_ENABLED = 0 'THBF_DISABLED = 1 'THBF_DISMISSONCLICK = 2 'THBF_NOBACKGROUND = 4 'THBF_HIDDEN = 8 'THBF_NONINTERACTIVE = 10 'End Enum '#DEFINE CLSCTX_INPROC_HANDLER16 &h20 '#DEFINE CLSCTX_RESERVED1 &h40 '#DEFINE CLSCTX_RESERVED2 &h80 '#DEFINE CLSCTX_RESERVED3 &h100 '#DEFINE CLSCTX_RESERVED4 &h200 '#DEFINE CLSCTX_NO_CODE_DOWNLOAD &h400 '#DEFINE CLSCTX_RESERVED5 &h800 '#DEFINE CLSCTX_NO_CUSTOM_MARSHAL &h1000 '#DEFINE CLSCTX_ENABLE_CODE_DOWNLOAD &h2000 '#DEFINE CLSCTX_NO_FAILURE_LOG &h4000 '#DEFINE CLSCTX_DISABLE_AAA &h8000 '#DEFINE CLSCTX_ENABLE_AAA &h10000 '#DEFINE CLSCTX_FROM_DEFAULT_CONTEXT &h20000 '#DEFINE CLSCTX_ACTIVATE_32_BIT_SERVER &h40000 '#DEFINE CLSCTX_ACTIVATE_64_BIT_SERVER &h80000 '#DEFINE CLSCTX_ENABLE_CLOAKING &h100000 '#DEFINE CLSCTX_PS_DLL &h80000000 'Type THUMBBUTTON 'As THUMBBUTTONMASK dwMask 'As UINT iId 'As UINT iBitmap 'As HICON hIcon 'As WString*260 szTip 'As THUMBBUTTONFLAGS dwFlags 'End Type 'Type ITaskbarList3Vtbl_ As ITaskbarList3Vtbl ' 'Type ITaskbarList3 'lpVtbl As ITaskbarList3Vtbl_ Ptr 'End Type ' 'Type ITaskbarList3Vtbl 'QueryInterface As Function (Byval As ITaskbarList3 Ptr,Byval As IID Ptr, Byval As Any Ptr Ptr) As HRESULT 'AddRef As Function(Byval As ITaskbarList3 Ptr) As HRESULT 'Release As Function(Byval As ITaskbarList3 Ptr) As HRESULT 'HrInit As Function(Byval As ITaskbarList3 Ptr) As HRESULT 'AddTab As Function(Byval As ITaskbarList3 Ptr,a As HWND) As HRESULT 'DeleteTab As Function(Byval As ITaskbarList3 Ptr,a As HWND) As HRESULT 'ActivateTab As Function(Byval As ITaskbarList3 Ptr,a As HWND) As HRESULT 'SetActiveAlt As Function(Byval As ITaskbarList3 Ptr,a As HWND) As HRESULT 'MarkFullscreenWindow As Function(Byval As ITaskbarList3 Ptr,a As HWND,fFullscreen As BOOL) As HRESULT 'SetProgressValue As Function (ITL As ITaskbarList3 Ptr,hwnd As HWND ,ullCompleted As Ulongint,ullTotal As Ulongint) As HRESULT 'SetProgressState As Function(ITL As ITaskbarList3 Ptr,hwnd As HWND,tbpFlags As TBPFLAG) As HRESULT 'RegisterTab As Function(ITL As ITaskbarList3 Ptr,hwndTab As HWND ,hwndMDI As HWND) As HRESULT 'UnregisterTab As Function(ITL As ITaskbarList3 Ptr,hWndTab As HWND) As HRESULT 'SetTabOrder As Function(ITL As ITaskbarList3 Ptr,hWndTab As HWND,hWndInsertBefore As HWND) As HRESULT 'SetTabActive As Function(ITL As ITaskbarList3 Ptr,hWndTab As HWND,hWndMDI As HWND,tbatFlags As DWORD)As HRESULT 'ThumbBarAddButtons As Function(ITL As ITaskbarList3 Ptr,hWnd As HWND,cButtons As UINT,pButton As THUMBBUTTON Ptr)As HRESULT 'ThumbBarUpdateButtons As Function(ITL As ITaskbarList3 Ptr,hWnd As HWND,cButtons As UINT,pButton As THUMBBUTTON Ptr)As HRESULT 'ThumbBarSetImageList As Function(ITL As ITaskbarList3 Ptr,hWnd As HWND,himl As HIMAGELIST)As HRESULT 'SetOverlayIcon As Function(ITL As ITaskbarList3 Ptr,hWnd As HWND,hIcon As HICON,pszDescription As LPCWSTR)As HRESULT 'SetThumbnailTooltip As Function(ITL As ITaskbarList3 Ptr,hWnd As HWND,pszTip As LPCWSTR)As HRESULT 'SetThumbnailClip As Function(ITL As ITaskbarList3 Ptr,hWnd As HWND,prcClip As LPRECT)As HRESULT 'End Type 'Dim Shared CLSID_TaskbarList As IID = Type(&h56FDF344, &hFD6D, &h11D0, {&h95, &h8a, &h00, &h60, &h97, &hc9, &ha0, &h90}) 'Dim Shared IID_ITaskbarList3 As IID = Type(&hEA1AFB91, &h9E28, &h4B86, {&h90, &hE9, &h9E, &h9F, &h8A, &h5E, &hEF, &hAF}) Dim As Integer ev, pct Dim As HWND hwnd Dim As RECT rec Dim As ITaskbarList3 Ptr tl3 hwnd = OpenWindow("", 0, 0, 300, 80) ProgressBarGadget(1, 10,10, 260, 20, 0, 100) CoInitialize(Null) CoCreateInstance(@CLSID_TaskBarList,Null,CLSCTX_INPROC_SERVER,@IID_ITaskBarList3,@tl3) tl3->lpVtbl->HrInit(tl3) tl3->lpVtbl->SetProgressValue(tl3,hwnd,0,100) tl3->lpVtbl->SetProgressState(tl3,hwnd,TBPF_NORMAL) GetClientRect(hwnd, @rec) rec.right /= 2 rec.bottom /= 2 tl3->lpVtbl->SetThumbnailClip(tl3,hwnd, @rec) Do ev = WindowEvent() If ev = 0 Then If pct = 101 Then FreeGadget(1) SetWindowText(hwnd, "Ошибка") tl3->lpVtbl->SetProgressState(tl3,hwnd,TBPF_ERROR) Else SetWindowText(hwnd, Str(pct)) SetGadgetState(1, pct) tl3->lpVtbl->SetProgressValue(tl3,hwnd,pct,100) pct += 1 Endif Sleep 20 Endif Sleep(1) Loop Until ev = EventClose If tl3 Then tl3->lpVtbl->Release(tl3) CoUninitialize() Endif