views:

65

answers:

1

I'm creating a HUD window for inspecting biz entities in my WinForms application.

I wanted to have a completely different style of window (minimize the content area and showing only the TitleBar, no system buttons, etc) so I created a WPF application for this.

The problem is that I want this Window to 'live' inside my WinForms application. I can't just add the WPF as an OwnedForm or set the main Form as the Owner of the WPF window.

So, how can achive this?

EDIT: Thanks to pst I found the answer. Here is the snippet:

System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(_inspector);
WindowInteropHelper inspectorHelper = new WindowInteropHelper(_inspector);
inspectorHelper.Owner = this.Handle;
_inspector.Show();
+2  A: 

A WPF Window has a Win32-window handle/context.

See WindowInteropHelper. You can use this with Win32 (or perhaps there is WinForms support?) to set the owner window of the WPF Window. Be aware the handle does not exist until the "source initialized" (?) event.

However, using just WinForms, you may be able to customize the titlebar as much as you need (you can overwrite the drawing itself via Win32, and I think you lose all the control boxes without going this far).

There are lots of google results on this topic if you use the correct keywords.

pst
The WindowInteropHelper worked fine! It seems I didn't use the correct keywords, I've been searching the all day for it.Thanks again!
jpsstavares