Upload
magdalen-mckenzie
View
224
Download
2
Tags:
Embed Size (px)
Citation preview
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
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
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
4
Rewrite Or Evolve?Rewrite Or Evolve?
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.
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;
7
WPF inside hwndWPF inside hwnd
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(…); }}}}
9
DirectX inside WPFDirectX inside WPF
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
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
12
File Edit View Help
Win32
DirectX
WPF
Airspace – caution!Airspace – caution!
WPF
File Edit View Help
Win32
DirectX
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)
14
Mixed Application IdeasMixed Application Ideas
New New canvascanvas
New chromeNew chrome
Faster Faster canvas?canvas?
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
16
WPF inside MFCWPF inside MFC
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
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
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/
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
21
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.