Calling the new features of the Windows 7 taskbar with managed code

  

Windows 7 Beta has been released publicly and can be downloaded from http://www.microsoft.com/windows/windows-7/beta-download.aspx. W7 has made a lot of improvements on the taskbar. For the new features of the taskbar, you can check out http://blogs.msdn.com/e7/archive/2008/11/20/happy-anniversary-windows-on-the -evolution-of-the-taskbar.aspx. If you want to develop Windows 7, it is best to look at the white paper, which can be downloaded from http://code.msdn.microsoft.com/PDC08WhitePapers/Release/ProjectReleases.ASPx?ReleaseId=1797. We will use Windows 7 Taskbar Enhancements for our development of the taskbar. Here we mainly implement Overlay Icons and Progress Bars in the icon of the taskbar. The Windows 7 SDK Beta may also be required during the implementation process.

Start

First find the ShObjIdl.idl file in the Windows SDK. If you don't have the SDK installed, you can download it later. This is an interface definition language file. For convenience of calling, we can similarly

1HRESULT SetProgressValue(
2 [in] HWND hwnd,
3 [in] ULONGLONG ullCompleted,
4 [ ,null,null,3],In] ULONGLONG ullTotal);

This interface declaration is changed to

1HRESULT SetProgressValue(
2 [in] long hwnd,
3 [in] ULONGLONG ullCompleted,
4 [in] ULONGLONG ullTotal);

is to change the HWND type to long. Then use midl to convert the modified idl file to a binary tlb file, ShObjTlb.tlb is the generated file, and ShObjIdl.idl is the original file.


Use tlbimp to generate the managed dll file from the tlb file.


Add a reference to the dll in the project, and then you can call the method like a managed dll.

To achieve progress in the taskbar icon, two functions, SetProgressState and SetProgressState, are used.

The first parameter of the SetProgressState method is the handle, the second parameter is an enumeration variable, indicating the state of the current icon, we can define an enumeration to represent these states

1private enum TbpFlag
2 {
3 TBPF_ERROR = 1,
4 TBPF_PAUSED = 2,
5 TBPF_NORMAL = 3,
6 TBPF_INDETERMINATE = 4,
7 };

Then you can use SetProgressState( (int)this.Handle , TBPFLAG.TBPF_NORMAL); set the icon state to normal.

SetProgressValue((int)this.Handle, 50, 100); You can set the progress, the first parameter is the handle, the second parameter is the completed quantity, and the third parameter is the total amount.

For details on how to use these functions, please check the Windows 7 SDK or the English version of the MSDN Library.

Effects

20% Completion:


50% Completion:


100% Complete Time:


Others

According to this method and referring to the PDC2008 white paper, you can implement other new Windows 7 features in a managed language.

Unmanaged code

If you implement this function in C++, it will be easier. You can refer to the Windows SDK. The path is Microsoft SDKsWindowsv7.0SampleswinuiShellTaskbarIntegrationPeripheralStatus

Copyright © Windows knowledge All Rights Reserved