Forum > Win32/64
Task Icon Progress Bar under Windows
kupferstecher:
Hello,
just want to share how to use the taskbar progress bar under Windows. I didn't find any Lazarus-specific description on the web, so it might be helpful for someone. Unfortunately its a Windows only solution.
See attached screenshots. The windows task icons offer the possibility to show a progress bar, this is useful for showing the progress of longer lasting actions, when the user doesn't have the application window in the foreground.
Regards~
--
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ShlObj, comobj, Win32Int, InterfaceBase, LCLIntf; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure FormCreate(Sender: TObject); private FTaskBarList: ITaskbarList3; AppHandle: THandle; public end; var Form1: TForm1; IMPLEMENTATION {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin FTaskBarList.SetProgressState(AppHandle, TBPF_NOPROGRESS); Application.Title:= 'project1';end; procedure TForm1.Button2Click(Sender: TObject);begin FTaskBarList.SetProgressState(AppHandle, TBPF_Normal); FTaskBarList.SetProgressValue(AppHandle, 40, 100); Application.Title:= 'progress';end; procedure TForm1.Button3Click(Sender: TObject);begin FTaskBarList.SetProgressState(AppHandle, TBPF_Error); FTaskBarList.SetProgressValue(AppHandle, 50, 100); Application.Title:= 'error';end; procedure TForm1.Button4Click(Sender: TObject);begin sleep(2000); LCLIntf.SetForegroundWindow(AppHandle); end; procedure TForm1.FormCreate(Sender: TObject);begin AppHandle := TWin32WidgetSet(WidgetSet).AppHandle; FTaskBarList := CreateComObject(CLSID_TaskbarList) as ITaskbarList3; end; end.
Handoko:
I ever wondered how to do it.
Thanks for sharing it
440bx:
Yes, thank you for sharing that. Very nice.
AlexTP:
Win32TaskbarProgress component
https://forum.lazarus.freepascal.org/index.php/topic,52632.0.html
ASerge:
--- Quote from: kupferstecher on March 31, 2019, 12:57:55 pm ---just want to share how to use the taskbar progress bar under Windows. I didn't find any Lazarus-specific description on the web, so it might be helpful for someone. Unfortunately its a Windows only solution.
--- End quote ---
Don't forget, that WinXP doesn't support ITaskbarList3.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);var Base: IUnknown;begin// AppHandle := TWin32WidgetSet(WidgetSet).AppHandle; AppHandle := Application.Handle; Base := CreateComObject(CLSID_TaskbarList); if not Supports(Base, ITaskbarList3, FTaskBarList) then FTaskBarList := nil;end;and replace "FTaskBarList." with "if Assigned(FTaskBarList) then FTaskBarList.".
Navigation
[0] Message Index
[#] Next page