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

Post on 17-Jan-2018

226 views 0 download

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

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

CL12

Microsoft Confidential

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

> Introduction> Demos Demos Demos…> Roadmap

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…

Great Windows Applications

Demo

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

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

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

New Windows API Code Pack Version

Version 1.0.1

announcing

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

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

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);

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)

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)

Creating Thumbnail ToolbarsWinFormsAddButtons(IntPtr windowHandle,

params ThumbnailToolbarButton[]

buttons)

WPF: AddButtons(UIElement control,

params ThumbnailToolbarButton[]

buttons)

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)

Taskbar

JumpLists, Thumbnail Buttons, Clipping, and custom Preview

Demos

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

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);

Libraries

Demo

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

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

MSDN Reader

Light-Aware User Interface

Demo

XNA Racing Game

Ambient Light and Accelerometer Sensors

Demo

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

Windows 7 Managed Roadmap

Today Tomorrow

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

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

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

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

forms online atMicrosoftPDC.com

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….

© 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.

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

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>