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

  

Preparing

Windows 7 Beta has been released publicly from http://www.microsoft.com/windows/windows-7/beta -download.aspx download. 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, available from http://code.msdn.microsoft.com/PDC08WhitePapers/Release/ProjectReleases.aspx? ReleaseId=1797 download. 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.

Getting Started

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 [in] ULONGLONG ullTotal);

Such an interface declaration is changed to

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

That is HWND Type is changed 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.


Then use tlbimp to generate the managed dll file for the tlb file.


Add a reference to the dll in your project, and then you can call the methods 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 TbpFlag2 {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); The icon status is set to the normal state.

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

When 20% is completed:


When 50% is completed:


100% completed Time:


Others

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

Unmanaged code

If you implement this feature in C++, it will be easier. You can refer to the Windows SDK. The path is Microsoft SDKsWindowsv7.0SampleswinuiShellTaskbarIntegrationPeripheralStatus
This article code or material download

Copyright © Windows knowledge All Rights Reserved