Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » How to set progress in taskbar button
How to set progress in taskbar button [message #49235] Wed, 10 January 2018 08:48 Go to next message
koldo is currently offline  koldo
Messages: 2922
Registered: August 2008
Veteran
This code snippet displays a progress indicator in the Windows 7-10 taskbar button.
It has just 3 functions: Init(), SetValue(val, max) and End().

index.php?t=getfile&id=5482&private=0

#if defined(PLATFORM_WIN32) 

#include <winnls.h>
#include <winnetwk.h>

#define Ptr Ptr_
#define CY tagCY
#include <wincon.h>
#include <shlobj.h>
#undef CY
#undef Ptr

class TaskbarProgress {
public:
	TaskbarProgress() : m_hWnd(0) {}
	void Init() {
		m_hWnd = ::GetActiveWindow();
		HRESULT hres;
		hres = CoInitialize(NULL);
		hres = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&m_pTaskBarlist);
		m_pTaskBarlist->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
	}
	void SetValue(int val, int max) {
		ASSERT(val >= 0 && val <= max);
		if (!m_hWnd)
			return;
		m_pTaskBarlist->SetProgressValue(m_hWnd, val, max);
	}
	void End() {
		if (!m_hWnd)
			return;
		m_pTaskBarlist->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
		m_pTaskBarlist->Release();
		m_hWnd = 0;
	}
	
private:
	ITaskbarList3* m_pTaskBarlist;
	HWND m_hWnd;
};

#endif
  • Attachment: index.jpg
    (Size: 12.82KB, Downloaded 118 times)


Best regards
Iñaki
Re: How to set progress in taskbar button [message #49240 is a reply to message #49235] Wed, 10 January 2018 10:53 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 591
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello,

This should be also be possible with GTK backend. For example my KDE desktop supports such feature, too. I belive Unity and Gnome is also possible to do that.

If we want to support such feature we should have multiplatform code whenever it is possible.

Sincerely,
Klguier


Ultimate++ - one framework to rule them all.
Re: How to set progress in taskbar button [message #49244 is a reply to message #49240] Wed, 10 January 2018 11:42 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 535
Registered: August 2007
Location: Turkey
Contributor
This is nice, and useful. Thanks!

IIRC, KDE Plasma (and probably Gnome) version is based on Unity's dbus service. Either you'll need to wrap up a certain portion of GNOME dbus api, or you'll need a full dbus wrapper.

Best regards,
Oblivion.

[Updated on: Wed, 10 January 2018 11:44]

Report message to a moderator

Re: How to set progress in taskbar button [message #49255 is a reply to message #49244] Thu, 11 January 2018 08:25 Go to previous message
koldo is currently offline  koldo
Messages: 2922
Registered: August 2008
Veteran
This is just a code snippet Smile

If anybody has the knowledge to do it in KDE and GTK, it could be included into main U++ or in Bazaar.


Best regards
Iñaki

[Updated on: Thu, 11 January 2018 08:25]

Report message to a moderator

Previous Topic: Read a text file and assign values to variables int and double
Next Topic: THISFN and Thread
Goto Forum:
  


Current Time: Tue Feb 19 03:28:59 CET 2019

Total time taken to generate the page: 0.01263 seconds