www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - Windows 7 taskbar progress example

Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I had to figure out how to do this for my app, so here's some sample 
code for you enjoyment. :)

Needs a Tango and dwt-win install to build.  The other required files 
are in the attachment.


Here's the main file, that shows how the use the StatusbarProgress 
wrapper class:

---
module taskbartest;

import tango.io.Stdout;
import tango.sys.win32.Types;

import dwt.DWT;
import dwt.widgets.Display;
import dwt.widgets.Shell;

import link;
import mswindows.taskbarprogress;


void main() {
	auto display = new Display();
	auto shell = new Shell(display);
	shell.open();

	TaskbarProgress tbProgress;
	try {
		tbProgress = new TaskbarProgress(shell.handle);

		// try out setProgressValue and setProgressState
		tbProgress.setProgressValue(33, 100);
		tbProgress.setProgressState(TBPF_PAUSED);
		Stdout.formatln("Nice, eh?");
	}
	catch (Exception e) {
		Stdout.formatln("{}", e);
	}		

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
	if (tbProgress)
		tbProgress.dispose();
}
---
Jun 05 2010