unit W7TaskBar;
interface
uses Forms;
type
TTaskBarProgressState = (tbpsNone, tbpsIndeterminate, tbpsNormal, tbpsError, tbpsPaused);
TFormHelper =
class helper
for TCustomForm
procedure SetProgressState(
const AState: TTaskBarProgressState);
procedure SetProgressValue(
const ACurrent, AMax: UInt64);
end;
implementation
uses
ComObj, Types;
const
TASKBAR_CID: TGUID = '
{56FDF344-FD6D-11d0-958A-006097C9A090}';
const
TBPF_NOPROGRESS = 0;
TBPF_INDETERMINATE = 1;
TBPF_NORMAL = 2;
TBPF_ERROR = 4;
TBPF_PAUSED = 8;
type
ITaskBarList3 =
interface(IUnknown)
['
{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}']
procedure HrInit;
stdcall;
procedure AddTab(hwnd: THandle);
stdcall;
procedure DeleteTab(hwnd: THandle);
stdcall;
procedure ActivateTab(hwnd: THandle);
stdcall;
procedure SetActiveAlt(hwnd: THandle);
stdcall;
procedure MarkFullscreenWindow(hwnd: THandle; fFullscreen: Boolean);
stdcall;
procedure SetProgressValue(hwnd: THandle; ullCompleted: UInt64; ullTotal: UInt64);
stdcall;
procedure SetProgressState(hwnd: THandle; tbpFlags: Cardinal);
stdcall;
procedure RegisterTab(hwnd: THandle; hwndMDI: THandle);
stdcall;
procedure UnregisterTab(hwndTab: THandle);
stdcall;
procedure SetTabOrder(hwndTab: THandle; hwndInsertBefore: THandle);
stdcall;
procedure SetTabActive(hwndTab: THandle; hwndMDI: THandle; tbatFlags: Cardinal);
stdcall;
procedure ThumbBarAddButtons(hwnd: THandle; cButtons: Cardinal; pButtons: Pointer);
stdcall;
procedure ThumbBarUpdateButtons(hwnd: THandle; cButtons: Cardinal; pButtons: Pointer);
stdcall;
procedure ThumbBarSetImageList(hwnd: THandle; himl: THandle);
stdcall;
procedure SetOverlayIcon(hwnd: THandle; hIcon: THandle; pszDescription: PChar);
stdcall;
procedure SetThumbnailTooltip(hwnd: THandle; pszDescription: PChar);
stdcall;
procedure SetThumbnailClip(hwnd: THandle;
var prcClip: TRect);
stdcall;
end;
var
GlobalTaskBarInterface: ITaskBarList3;
procedure TFormHelper.SetProgressState(
const AState: TTaskBarProgressState);
const
Flags:
array[TTaskBarProgressState]
of Cardinal = (0, 1, 2, 4, 8);
begin
if GlobalTaskBarInterface <>
nil then
GlobalTaskBarInterface.SetProgressState(
Handle, Flags[AState]);
end;
procedure TFormHelper.SetProgressValue(
const ACurrent, AMax: UInt64);
begin
if GlobalTaskBarInterface <>
nil then
GlobalTaskBarInterface.SetProgressValue(
Handle, ACurrent, AMax);
end;
procedure InitializeAPI;
var
Unk: IInterface;
begin
CoInitializeEx(
nil, 0);
try
Unk := CreateComObject(TASKBAR_CID);
if Unk =
nil then Exit;
GlobalTaskBarInterface := Unk
as ITaskBarList3;
GlobalTaskBarInterface.HrInit;
except
GlobalTaskBarInterface :=
nil;
end;
end;
initialization
InitializeAPI;
finalization
GlobalTaskBarInterface :=
nil;
end.