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 previous message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior 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 420 times)


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: error in examples
Next Topic: THISFN and Thread
Goto Forum:
  


Current Time: Fri Apr 26 14:46:17 CEST 2024

Total time taken to generate the page: 0.03775 seconds