21
1 Windows Presentation Windows Presentation Foundation ("Avalon"): Foundation ("Avalon"): Integrating With Your Integrating With Your Win32/MFC Application Win32/MFC Application Nick Kramer Nick Kramer PRS313 PRS313 Lead Program Manager Lead Program Manager Microsoft Corporation Microsoft Corporation

1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

Embed Size (px)

Citation preview

Page 1: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

1

Windows Presentation Foundation Windows Presentation Foundation ("Avalon"): Integrating With Your ("Avalon"): Integrating With Your Win32/MFC ApplicationWin32/MFC Application

Nick KramerNick KramerPRS313PRS313Lead Program ManagerLead Program ManagerMicrosoft CorporationMicrosoft Corporation

Page 2: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

2

How Do I Get There How Do I Get There From Here?From Here?

Do I rewrite everything?Do I rewrite everything?

Too much code to rewriteToo much code to rewrite

Existing plug-insExisting plug-ins

Existing controlsExisting controls

Existing documentsExisting documents

Page 3: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

3

Integration!Integration!

Can use WPF with existing codeCan use WPF with existing codeWPF inside existing codeWPF inside existing code

Existing code inside WPFExisting code inside WPF

Integrate at the component levelIntegrate at the component level

Maximum richness => all WPFMaximum richness => all WPF

Page 4: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

4

Rewrite Or Evolve?Rewrite Or Evolve?

Page 5: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

5

HwndSource and HwndSource and HwndHostHwndHost

WPF inside hwnd = HwndSourceWPF inside hwnd = HwndSource

hwnd inside WPF = HwndHosthwnd inside WPF = HwndHost

Hwnds can be:Hwnds can be:Pure Win32, DirectX, MFC, GDI, GDI+, Pure Win32, DirectX, MFC, GDI, GDI+, etc.etc.

Page 6: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

6

WPF inside hwndWPF inside hwnd

HwndSource makes WPF look like a HwndSource makes WPF look like a big hwndbig hwnd

HwndSource source = new HwndSource(…);HwndSource source = new HwndSource(…);source.RootVisual = myWpfStuff;source.RootVisual = myWpfStuff;HWND hwnd = source.Handle; HWND hwnd = source.Handle;

Page 7: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

7

WPF inside hwndWPF inside hwnd

Page 8: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

8

hwnd inside WPFhwnd inside WPF

HwndHost makes hwnd look like a HwndHost makes hwnd look like a WPF controlWPF control

class MyHwndHost : HwndHost {class MyHwndHost : HwndHost { override BuildWindowCore(hwndParent)override BuildWindowCore(hwndParent) {{ return CreateWindowEx(…);return CreateWindowEx(…); }}}}

Page 9: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

9

DirectX inside WPFDirectX inside WPF

Page 10: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

10

Mixed App ConsiderationsMixed App Considerations

Higher long-term cost, lower initial Higher long-term cost, lower initial costcost

Run in browserRun in browser

Integrate your business logicIntegrate your business logic

Using XAML in C++Using XAML in C++

Airspace & layered windowsAirspace & layered windows

Page 11: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

11

WPF

File Edit View Help

Win32

DirectX

AirspaceAirspaceEach pixel belongs to one hwndEach pixel belongs to one hwnd

File Edit View Help

Win32

WPF

DirectX

Page 12: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

12

File Edit View Help

Win32

DirectX

WPF

Airspace – caution!Airspace – caution!

WPF

File Edit View Help

Win32

DirectX

Page 13: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

13

Layered windowsLayered windows

WPF fully supports HRGNsWPF fully supports HRGNs

WPF does not support layered WPF does not support layered windows (WS_EX_LAYERED)windows (WS_EX_LAYERED)

Page 14: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

14

Mixed Application IdeasMixed Application Ideas

New New canvascanvas

New chromeNew chrome

Faster Faster canvas?canvas?

Page 15: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

15

Mixed Application IdeasMixed Application Ideas

Wizards and help systemsWizards and help systems

Generate HTML => Generate XAMLGenerate HTML => Generate XAML

WPF wrapper around an existing WPF wrapper around an existing controlcontrol

Page 16: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

16

WPF inside MFCWPF inside MFC

Page 17: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

17

SummarySummary

Can use WPF with existing codeCan use WPF with existing code

Maximum richness => all WPFMaximum richness => all WPF

Integration is for componentsIntegration is for components

Page 18: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

18

Info on hwnd integrationInfo on hwnd integration

System.Windows.HwndHostSystem.Windows.HwndHostSystem.Windows.HwndSourceSystem.Windows.HwndSourceArticle: Migration and Interop Article: Migration and Interop ArchitectureArchitecture

WPF newsgroupWPF newsgroupmicrosoft.public.windows.developer.winfx.microsoft.public.windows.developer.winfx.avalonavalon

http://blogs.msdn.com/nickkramer/http://blogs.msdn.com/nickkramer/[email protected]@microsoft.com

Page 19: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

19

Information on C++ and Information on C++ and managed codemanaged code

http://http://msdn.microsoft.com/visualcmsdn.microsoft.com/visualc// http://http://forums.microsoft.com/msdn/default.aforums.microsoft.com/msdn/default.aspx?ForumGroupIDspx?ForumGroupID=8=8microsoft.public.vc.language microsoft.public.vc.language http://http://msdn.microsoft.com/visualc/using/mumsdn.microsoft.com/visualc/using/multimedia/newcltimedia/newc//http://blogs.msdn.com/nikolad/http://blogs.msdn.com/nikolad/

Page 20: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

20

Related PDC TalksRelated PDC Talks(PRS321) Windows Forms: Integrating (PRS321) Windows Forms: Integrating Windows Forms and WPFWindows Forms and WPF(FUN318) Windows Vista: A Case Study (FUN318) Windows Vista: A Case Study Using Win32/WinFX Integration to Light-Using Win32/WinFX Integration to Light-Up Your Win32 Application on Windows Up Your Win32 Application on Windows VistaVista(PRS324) WPF: Using Data in Your WPF (PRS324) WPF: Using Data in Your WPF ApplicationsApplications(PRS330) WPF: Creating Rich Content (PRS330) WPF: Creating Rich Content Experiences in Your ApplicationsExperiences in Your Applications

Related PDC Hands-on LabsRelated PDC Hands-on LabsMoving Win32 Applications to WPFMoving Win32 Applications to WPFIntegrating MFC and Windows FormsIntegrating MFC and Windows Forms

Page 21: 1 Windows Presentation Foundation ("Avalon"): Integrating With Your Win32/MFC Application Nick Kramer PRS313 Lead Program Manager Microsoft Corporation

21

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.