Use managed code to call new functions of Windows 7 taskbar

Source: Internet
Author: User
ArticleDirectory
    • Preparation
    • Start
    • Effect
    • Others
    • Download Code and related files
Preparation

Windows 7 Beta has been publicly released and can be downloaded from http://www.microsoft.com/windows/windows-7/beta-download.aspx. W7 has made great improvements on the taskbar. For details about the new features of the taskbar, refer to the overview. If you want to develop Windows 7, it is best to take a look at the White Paper, can you from the http://code.msdn.microsoft.com/PDC08WhitePapers/Release/ProjectReleases.aspx? Releaseid = 1797 download. Windows 7 taskbar enhancements is used for the task bar development. Here we mainly display the progress (overlay icons and progress bars) in the icon of the taskbar ). Windows 7 SDK beta may also be required during implementation.

Start

First, find the shobjidl. IDL file in the Windows SDK. If the SDK is not installed, download it later. This is an Interface Definition Language file.

1 Hresult setprogressvalue (
2 [ In ] Hwnd,
3 [ In ] Ulonglong ullcompleted,
4 [ In ] Ulonglong ulltotal );

This interface declaration is changed

1 Hresult setprogressvalue (
2 [ In ] Long Hwnd,
3 [ In ] Ulonglong ullcompleted,
4 [ In ] Ulonglong ulltotal );

That is, change the hwnd type to long. Then, use midl to generate a binary TLB file from the modified IDL file. shobjtlb. TLB is the generated file, and shobjidl. IDL is the original file.


Use tlbimp to generate a hosted DLL file.


Add a reference to the DLL in the project, and then you can call the method in it just like referencing the hosted DLL.
To display progress in the taskbar icon, you need to use two functions: setprogressstate and setprogressstate.
The first parameter of the setprogressstate method is the handle, and the second parameter is an enumeration variable, indicating the status of the current icon. You can define an enumeration to display these statuses.

1 Private   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); To set the icon status to normal.
Setprogressvalue (INT) This. Handle, 50,100); you can set the progress. The first parameter is the handle, the second parameter is the finished amount, and the third parameter is the total amount.
For more information about how to use these functions, see the Windows 7 SDK or the msdn library in the English version.

Effect

20% completed:


50% completed:


100% completed:

Others

Follow this method and refer to the introduction in the pdc2008 White Paper to implement new features of other Windows 7 in managed languages.

Unmanaged Code

If you use C ++ to implement this function, you can refer to the Windows SDK. The path is Microsoft sdks \ windows \ v7.0 \ samples \ winui \ shell \ taskbarintegration \ peripheralstatus.

Download Code and related files

1. Complete example download

2. shobjidl. IDL download

Update

You can also use the Windows API code pack for Microsoft. NET Framework to use the new features in Windows 7. For more information, see http://code.msdn.microsoft.com/WindowsAPICodePack

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.