Difference between revisions of "Win32TaskbarProgress"

From Lazarus wiki
Jump to navigationJump to search
m (→‎Usage: Fix typo)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=About=
+
{{Platform only|Windows}}
 +
 
 +
==About==
  
 
This is unit which contains the class to control the progressbar over the Windows 7+ taskbar button. The demo looks like this:
 
This is unit which contains the class to control the progressbar over the Windows 7+ taskbar button. The demo looks like this:
Line 5: Line 7:
 
[[Image:Win32TaskbarProgressDemo.png]]
 
[[Image:Win32TaskbarProgressDemo.png]]
  
Taskbar button can be colored in several ways:
+
Taskbar button progress can have several styles:
  
 
* none (inactive)
 
* none (inactive)
Line 13: Line 15:
 
* marquee floating animation (progress value is ignored, it's constantly changing animation from min to max)
 
* marquee floating animation (progress value is ignored, it's constantly changing animation from min to max)
  
Author: Alexey Torgashin
 
  
License: MIT
+
==Author==
 +
 
 +
Alexey Torgashin
 +
 
 +
==License==
 +
 
 +
MIT
  
=Usage=
+
==Usage==
  
 
In the form's OnShow (or maybe OnCreate) create the object like this:
 
In the form's OnShow (or maybe OnCreate) create the object like this:
  
uses
+
<syntaxhighlight lang="pascal">
  win32taskbarprogress;
+
uses
 +
  win32taskbarprogress;
  
procedure TForm1.FormShow(Sender: TObject);
+
procedure TForm1.FormShow(Sender: TObject);
begin
+
begin
  GlobalTaskbarProgress:= TWin7TaskProgressBar.Create;
+
  GlobalTaskbarProgress:= TWin7TaskProgressBar.Create;
end;
+
end;
 +
</syntaxhighlight>
  
 
And then call properties of this object like this:
 
And then call properties of this object like this:
  
//to change state: none, green, yellow, red, floating
+
<syntaxhighlight lang="pascal">
GlobalTaskbarProgress.Style:= TTaskBarProgressStyle(ComboBoxStyle.ItemIndex);
+
  //to change state: none, green, yellow, red, floating
 +
  GlobalTaskbarProgress.Style:= TTaskBarProgressStyle(ComboBoxStyle.ItemIndex);
 
   
 
   
//to change progress value 0 to 100
+
  //to change progress value 0 to 100
GlobalTaskbarProgress.Progress:= Edit1.Value;
+
  GlobalTaskbarProgress.Progress:= Edit1.Value;
 +
</syntaxhighlight>
  
=Download=
+
Author tried to initialise the object in the "initialization" part of win32taskbarprogress, but failed, maybe because the Application.Handle is not initialised so early.
 +
 
 +
==Download==
  
 
Unit file and demo project: https://github.com/Alexey-T/Win32TaskbarProgress
 
Unit file and demo project: https://github.com/Alexey-T/Win32TaskbarProgress
 +
 +
[[Category:Lazarus]]
 +
[[Category:Components]]
 +
[[Category:Code Snippets]]
 +
[[Category:Windows]]

Latest revision as of 11:01, 9 November 2021

Windows logo - 2012.svg

This article applies to Windows only.

See also: Multiplatform Programming Guide

About

This is unit which contains the class to control the progressbar over the Windows 7+ taskbar button. The demo looks like this:

Win32TaskbarProgressDemo.png

Taskbar button progress can have several styles:

  • none (inactive)
  • green progress
  • yellow progress (looks like paused state)
  • red progress (looks like error state)
  • marquee floating animation (progress value is ignored, it's constantly changing animation from min to max)


Author

Alexey Torgashin

License

MIT

Usage

In the form's OnShow (or maybe OnCreate) create the object like this:

uses
  win32taskbarprogress;

procedure TForm1.FormShow(Sender: TObject);
begin
  GlobalTaskbarProgress:= TWin7TaskProgressBar.Create;
end;

And then call properties of this object like this:

  //to change state: none, green, yellow, red, floating
  GlobalTaskbarProgress.Style:= TTaskBarProgressStyle(ComboBoxStyle.ItemIndex);
 
  //to change progress value 0 to 100
  GlobalTaskbarProgress.Progress:= Edit1.Value;

Author tried to initialise the object in the "initialization" part of win32taskbarprogress, but failed, maybe because the Application.Handle is not initialised so early.

Download

Unit file and demo project: https://github.com/Alexey-T/Win32TaskbarProgress