pablox
pablox

Reputation: 641

Native Win32 window in WPF Control

I am developing an application that needs to a host native Win32 window and somehow i have no clues how to do that.

I need to create a WPF dialog window that could display native Win32 control on it. This dialog window will have WPF controls on it as well, so i am looking for some sort of Grid that i could take HWND of and send it to the unmanaged C++ control, so it could draw on it. Is that possible ?

I don't need to know what happens within that surface, just need to let C++ dll to draw on it and all i need to do is to pass HWND that has proper size (which i know).

I am kinda new to WPF (used to do win32 programming) and quite lost (but i now how to interface it to C# .NET etc)

Would be great if you could send me any hints :)

Upvotes: 10

Views: 4718

Answers (1)

Davide Piras
Davide Piras

Reputation: 44595

you can start by following the instructions/steps here: Hosting Win32 Content in WPF

from the article introduction:

A Walkthrough of Win32 Inside Windows Presentation Framework (HwndHost)

To reuse Win32 content inside WPF applications, use HwndHost, which is a control that makes HWNDs look like WPF content. Like HwndSource, HwndHost is straightforward to use: derive from HwndHost and implement BuildWindowCore and DestroyWindowCore methods, then instantiate your HwndHost derived class and place it inside your WPF application.

If your Win32 logic is already packaged as a control, then your BuildWindowCore implementation is little more than a call to CreateWindow.

then if you have a specific issue ask here in SO and people will help you on specific points.

Upvotes: 13

Related Questions