UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …)...

22
Bringing Existing C++ Code to Windows Store Apps Tarek Madkour Group Program Manager – Visual C+ + 3-000

Transcript of UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …)...

Page 1: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Bringing Existing C++ Code to Windows Store AppsTarek MadkourGroup Program Manager – Visual C++

3-000

Page 2: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Key DifferencesAPIsWinRT WrappingDemo

Agenda

Page 3: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

What’s Different?

New user experienceTouch-friendlyTrustBattery-powerFast and fluid

New user interfaceNew APIsAPI restrictionsPerformanceResponsiveness

Page 4: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

User InterfaceYour app needs new UI- Touch-friendly- Snaps & scales- Participates in contracts

DirectX for C++ appsXAML for C++ and .NET appsHTML5 for Java Script apps

Visual Studio 2012 has great tools for Windows 8 UI development

Page 5: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

API RestrictionsOnly a subset of Win32 and COM APIs are availableNew replacements available for most APIsRestricted API usage will result in:• Runtime failures• Rejection from Windows StoreRestriction applies to app code … and packaged 3rd party libraries

Page 6: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

API Restrictions: What to expect?UI: MFC, GDI

UI: DirectX still need to rethink user experience

ISO C++

VC++ Runtime (CRT, PPL, …)

C++/CLI

OS / Win32 WinRT + Win32 subset

COM / ATL ATL subset

3rd party libraries it depends

Everything else it depends

View

Model

Other

Page 7: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

API Restrictions: What to do?Preferred: Use the Windows Application Certification Kit• Run it on the original binaries• The generated API list is your “to do” list• The VS IDE can help find all references to APIs

in your list

Not Recommended: Use the pre-processor• Set the WINAPI_FAMILY_PARTITION macro• Work through the compiler errors

Page 8: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Demo: Windows App Cert Kit

Page 9: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

API Restriction: Threading ExampleThreading is key to performance and battery usage

Needed to strike a tough balance between:• Great user experience• Advanced usage• Compatibility

Result: the code example on this slide will not work

Page 10: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

API Restriction: Threading ExampleAvailable options for Windows Store apps:WinRT ThreadPool (namespace: Windows::System::Threading)

• Tailored for Windows Store app performance• Available only for Windows Store apps (not on Desktop)

Parallel Patterns Library Tasks• Higher level of abstraction• Available for both Windows Store and Desktop apps

ISO C++: std::thread, std::future• Low level of abstraction• Available cross-platform

Page 11: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

API Restriction: File I/O ExampleApplication Isolation is essential for Windows Store appsDefault access is restricted only to application dataApp manifest can request a few more permissionsAvailable options for Windows Store apps:WinRT Storage APIs • namespace: Windows::Storage

ISO C++• <fstream>, <filesystem>, …

Page 12: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

New APIs: WinRT

Devices

SensorsGeolocation Portable NFC

Communications & Data

Contracts

XML

Web

SMSNetworking

Notifications

Local & Cloud Storage

Streams

Background Transfer

User Interface

HTML5/CSS XAML DirectX Controls

Input Accessibility Printing

Data Binding

TilesSVG

FundamentalsApplication

ServicesAuthentication Cryptography GlobalizationMemory ManagementThreading/Timers

MediaVisual EffectsPlayback PlayToCapture

Page 13: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

New APIs: Asynchronous PatternCommon pattern for WinRT APIsImportant for creating smooth experiencesVery common pattern among key WinRT APIsFavors non-blocking scenariosProvides you the control over when to block if needed

Page 14: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Async: Basic Pattern

Page 15: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Async: Example

Page 16: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

WinRT ComponentsGreat for interoperating with Java Script and .NET apps• ... if you are a multi-language app developer• … if you are a library vendor seeking wider

exposure

C++/CX (or WRL) at the boundary to expose WinRT typesMaintain or change the C++ interfaceExtension SDKs make consumption from VS projects easier

Page 17: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

WinRT Components

Existing C++ Code

WinRT Wrapper

Java Script C# / VB (.NET) C++

DLL WinMD

Page 18: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Demo: Putting it all together

Page 19: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Rethink your app user experienceYour C++ code will move forward3rd party libraries need attentionNew world of WinRT available to you

Your existing investment in C++ code is very valuable in the new world of Windows Store applications.

Conclusion

Page 20: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

Related Sessions

• Tue 2:15 The Power of C++ Project Austin

• Tue 5:45 Connecting C++ Apps to the Cloud via Casablanca

• Wed

11:15

All About Performance

• Wed

1:45 DirectX Graphics Development

• Wed

5:15 Diving Deep Into C++/CX and WinRT

• Thu 10:15

Building Windows Store Apps using XAML and C++

• Fri 12:45

The Future of C++

Page 22: UI: MFC, GDI UI: DirectX still need to rethink user experience ISO C++ VC++ Runtime (CRT, PPL, …) C++/CLI OS / Win32 WinRT + Win32 subset COM.

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