Developing with the Windows API Code Pack for.NET Framework.

38
Developing with the Windows API Code Pack for .NET Framework Yochay Kiriaty Technical Evangelist Microsoft Corporation CL12

Transcript of Developing with the Windows API Code Pack for.NET Framework.

Page 1: Developing with the Windows API Code Pack for.NET Framework.

Developing with the Windows API Code Pack for .NET FrameworkYochay KiriatyTechnical EvangelistMicrosoft Corporation

CL12

Page 2: Developing with the Windows API Code Pack for.NET Framework.

Microsoft Confidential

Page 3: Developing with the Windows API Code Pack for.NET Framework.
Page 4: Developing with the Windows API Code Pack for.NET Framework.

Agenda> Why are we here?> The Windows API Code Pack

> Introduction> Demos Demos Demos…> Roadmap

Page 5: Developing with the Windows API Code Pack for.NET Framework.

Why Are We Here? (Part I)> We all write Windows Client

applications > Windows 7 has some cool features

> Taskbar> Shell and Libraries> Sensor and Location > Multitouch> New DirectX> Etc…

Page 6: Developing with the Windows API Code Pack for.NET Framework.

Great Windows Applications

Demo

Page 7: Developing with the Windows API Code Pack for.NET Framework.

Why We Are Here? (Part II)> We all write Windows Client

applications > Windows 7 has some cool features> All these features expose a native

(win32) API> Today - there are no equivalent Managed

APIs available to developers in the .NET Framework

> “Interoping” with Unmanaged Code might be a little difficult sometimes

Page 8: Developing with the Windows API Code Pack for.NET Framework.

Accessibility from managed code> Directly-callable using. NET interop

mechanisms> Example: RSS, Office

> C++/CLI or PInvoke signatures> Example: Application Recovery and Restart

> Raw Win32> Examples: Power Management, Windows

Vista Wizards> COM

> Examples: Search and Organize APIs> Extra difficult to call from managed code

> Examples: Common File Dialogs, Network Awareness

Easy

Hard

Page 9: Developing with the Windows API Code Pack for.NET Framework.

What is Windows API Code Pack?> Managed class library to access to

Windows (7) features> Windows Shell namespace (supporting for Shell property

system)> Taskbar Jumplists, Icon Overlay, Progress bar, Thumbnail,

etc… > Windows Task Dialogs , Explorer Browser and other controls > Direct3D 11.0 and DXGI 1.0/1.1 APIs > Sensor Platform APIs > Extended Linguistic Services APIs > Windows Restart Manager> Power APIs> Other….

> http://code.msdn.com/windowsAPICodePack

Page 10: Developing with the Windows API Code Pack for.NET Framework.

New Windows API Code Pack Version

Version 1.0.1

announcing

Page 11: Developing with the Windows API Code Pack for.NET Framework.

Windows API Code packShell> Taskbar> Libraries> Explorer Browser> Known Folders> Task Dialogs > Shell Properties

Page 12: Developing with the Windows API Code Pack for.NET Framework.

Main Features> Overlay icons & progress bars> Jump lists (destinations, tasks)> Thumbnail toolbars> Custom thumbnails> Tabbed thumbnails

Design Tip> Build a great Taskbar Icon> Forget about Quick Launch and the system tray

Windows Taskbar Features

Page 13: Developing with the Windows API Code Pack for.NET Framework.

Customizing the Jump ListAdding tasks

IObjectCollection* poc = ...;IShellLink* task = ...;Poc->AddObject(task);ICustomDestinationList* pcdl = ...;Pcdl->BeginList(...);IObjectArray* poa = ... poc;Pcdl->AddUserTasks(poa);Pcdl->CommitList();

JumpList jl = ...;jl.AddUserTasks(params IJumpListTask[] tasks);

Page 14: Developing with the Windows API Code Pack for.NET Framework.

Creating Thumbnail ToolbarsUINT wm_tbc = RegisterWindowMessage(

"TaskbarButtonCreated");MSG m; GetMessage(..., &m);if (m.message == wm_tbc) { ITaskbarList3* ptl = ...; THUMBBUTTON btn = {...}; ptl->ThumbBarAddButtons(m.hWnd, 1, &btn);}

WinForms: AddButtons(IntPtr windowHandle, params ThumbnailToolbarButton[] buttons)

WPF: AddButtons(UIElement control, params ThumbnailToolbarButton[] buttons)

Page 15: Developing with the Windows API Code Pack for.NET Framework.

Customizing Live ThumbnailsDwmSetWindowAttribute( ...,DWMWA_HAS_ICONIC_BITMAP,...);DwmSetWindowAttribute(...,DWMWA_FORCE_ICONIC_REPRESENTATION,...);/* in the WndProc */case WM_DWMSENDICONICTHUMBNAIL: HBITMAP hbm = ...; DwmSetIconicThumbnail(hwnd, hbm, ...);

TabbedThumbnailManager ttm = ...;ttm. AddThumbnailPreview(TabbedThumbnail preview)

Page 16: Developing with the Windows API Code Pack for.NET Framework.

Creating Thumbnail ToolbarsWinFormsAddButtons(IntPtr windowHandle,

params ThumbnailToolbarButton[]

buttons)

WPF: AddButtons(UIElement control,

params ThumbnailToolbarButton[]

buttons)

Page 17: Developing with the Windows API Code Pack for.NET Framework.

Setting Overlay Icon

WinForms TaskbarManager.SetOverlayIcon(

IntPtr windowHandle,System.Drawing.Icon icon, string accessibilityText)

WPF TaskbarManager.SetOverlayIcon(

System.Windows.Window window,System.Drawing.Icon icon, string accessibilityText)

Page 18: Developing with the Windows API Code Pack for.NET Framework.

Taskbar

JumpLists, Thumbnail Buttons, Clipping, and custom Preview

Demos

Page 19: Developing with the Windows API Code Pack for.NET Framework.

Shell and Libraries IntegrationA library is a collection of folders

> Folders are grouped together for a purpose> They don’t have to share a physical root

Very useful and user-friendlyDeveloper guidelines:

> Use correct version of the Common File Dialog (CFD)

> CFD may return a “library” as the savedlocation

> A library has a default save location> There are APIs for syncing with libraries

Page 20: Developing with the Windows API Code Pack for.NET Framework.

Customizing Live ThumbnailsIShellLibrary *pIShelLibrary;HRESULT hr = SHCreateLibrary( IID_PPV_ARGS(&pIShelLibrary));if (SUCCEEDED(hr)) { IShellItem *pIShellItem; SHAddFolderPathToLibrary(pIShelLibrary, L"C:\\Users\\Public\\Documents"); hr = pIShelLibrary->SaveInKnownFolder(FOLDERID_Libraries, L"My New Library", LSF_MAKEUNIQUENAME, &pIShellItem); pIShellItem->Release(); pIShelLibrary->Release(); }

ShellLibrary library = new ShellLibrary(name, true)library.Add(folderPath);

Page 21: Developing with the Windows API Code Pack for.NET Framework.

Libraries

Demo

Page 22: Developing with the Windows API Code Pack for.NET Framework.

Windows Sensor and Location PlatformDevelop better and more

productive user experiences > Enable environmentally

based applications

Uniform APIs for working with sensors > No need to target

vendor-specific APIs> Consistent interface for

sensors, extensions for location

> Access control and privacy

Application

Sensor API

Sensor Device

UMDF Driver

Page 23: Developing with the Windows API Code Pack for.NET Framework.

Ambient Light SensorOptimize for best user experience

> Change screen brightness> Out of the box with Windows 7

Drive adaptive user interface> LCD displays are difficult to read

outdoors in direct sunlight> Utilize knowledge of ambient

lighting conditions to improve PC usability

> Change contrast, color theme, and font size to be more readable in direct sunlight

Page 24: Developing with the Windows API Code Pack for.NET Framework.

MSDN Reader

Light-Aware User Interface

Demo

Page 25: Developing with the Windows API Code Pack for.NET Framework.

XNA Racing Game

Ambient Light and Accelerometer Sensors

Demo

Page 26: Developing with the Windows API Code Pack for.NET Framework.

Many more topics > Managed class library to access to

Windows (7) features> Windows Shell namespace (supporting for Shell property

system)> Taskbar Jumplists, Icon Overlay, Progress bar, Thumbnail,

etc… > Windows Task Dialogs, Explorer Browser and other

controls > Direct3D 11.0 and DXGI 1.0/1.1 APIs > Sensor Platform APIs > Extended Linguistic Services APIs > Windows Restart Manager> Power APIs> Other….

> http://code.msdn.com/windowsAPICodePack

Page 27: Developing with the Windows API Code Pack for.NET Framework.

Windows 7 Managed Roadmap

Today Tomorrow

Page 28: Developing with the Windows API Code Pack for.NET Framework.

Q2 / Q32010

Ver 2.0Expanded Shell

API coverage

Ver 1.5Fundamentals

Mar2010

Ver – 1.0.1Bug-fixes

Nov2009

Ver - 1.0Initial release

Aug2009

Ver - 0.9Preview

June 2009

Windows API Code Pack Roadmap

Page 29: Developing with the Windows API Code Pack for.NET Framework.

Call To Action > Windows 7 Application Compatibility> Optimize for Windows 7

> Use Windows 7 new Taskbar & jump lists> Become library aware

> Manage files & data with libraries> Create Amazing Expereinces:

> Enhance User Experience with Sensor and Location

> Adopt the new DirectX Graphic APIs > Develop for Multitouch

Page 30: Developing with the Windows API Code Pack for.NET Framework.

Resources> Windows Developer Center (MSDN)

> http://msdn.microsoft.com/en-us/windows/default.aspx

> Windows 7 Training Kit> Channel 9 -

http://channel9.msdn.com/learn/windows > Windows 7 Developers Blog

> http://windowsteamblog.com/blogs/developers/default.aspx

> Windows 7 on Channel 9 > http://channel9.msdn.com/windows

Page 31: Developing with the Windows API Code Pack for.NET Framework.
Page 32: Developing with the Windows API Code Pack for.NET Framework.

YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation

forms online atMicrosoftPDC.com

Page 33: Developing with the Windows API Code Pack for.NET Framework.

Learn More On Channel 9> Expand your PDC experience through

Channel 9

> Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses

channel9.msdn.com/learnBuilt by Developers for Developers….

Page 34: Developing with the Windows API Code Pack for.NET Framework.

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 35: Developing with the Windows API Code Pack for.NET Framework.
Page 36: Developing with the Windows API Code Pack for.NET Framework.

Windows 7 Taskbar and WPF 4> XAML support for JumpLists> Supported

> Overlay Icons and Progress Bar> JumpLists> Thumbnail Toolbars

> Not Supported> Custom thumbnail and thumbnail Preview> Thumbnail clipping

Page 37: Developing with the Windows API Code Pack for.NET Framework.

Taskbar using XAML

<JumpList.JumpList> <JumpList> <JumpTask ApplicationPath="notepad.exe" CustomCategory="External Tools" Description="Take Notes" Title="Start Notepad" IconResourcePath="notepad.exe" IconResourceIndex="0" /> <JumpTask ApplicationPath="calc.exe" CustomCategory="External Tools" Description="Perform some calculations" Title="Start Calculator" IconResourcePath="calc.exe" IconResourceIndex="0" /> </JumpList></JumpList.JumpList>

Page 38: Developing with the Windows API Code Pack for.NET Framework.