HwndHost Class

Definition

Hosts a Win32 window as an element within Windows Presentation Foundation (WPF) content.

public abstract class HwndHost : System.Windows.FrameworkElement, IDisposable, System.Windows.Interop.IKeyboardInputSink, System.Windows.Interop.IWin32Window
Inheritance
Derived
System.Windows.Forms.Integration.WindowsFormsHost
System.Windows.Interop.ActiveXHost
Implements

Inherited Members

System.Object

System.Windows.DependencyObject

System.Windows.FrameworkElement

System.Windows.Media.Visual

System.Windows.Threading.DispatcherObject

System.Windows.UIElement

Remarks

To host a Win32 window, create a class that derives from HwndHost. Override the BuildWindowCore method and create your Win32 window as a child of the parent window that is passed into the method.

Important

Although HwndHost derives from FrameworkElement, various properties of HwndHost that come from FrameworkElement and other intermediate classes such as UIElement are not generally mapped to possible Win32 equivalents. Also, not all FrameworkElement / UIElement input events transfer across the interoperation boundary. HwndHost derives from FrameworkElement primarily so that an HwndHost instance can be inserted into the widest variety of possible content models, and so that default FrameworkElement layout characteristics can apply. For more details on HwndHost, see WPF and Win32 Interoperation.

Constructors

HwndHost()

Initializes a new instance of the HwndHost class.

Fields

DpiChangedEvent

A RoutedEvent for when the DPI of the screen the HwndHost is on changes.

Properties

Handle

Gets the window handle of the hosted window.

Methods

BuildWindowCore(HandleRef)

When overridden in a derived class, creates the window to be hosted.

DestroyWindowCore(HandleRef)

When overridden in a derived class, destroys the hosted window.

Dispose()

Immediately frees any system resources that the object might hold.

Dispose(Boolean)

Immediately frees any system resources that the object might hold.

Finalize()

Performs the final cleanup before the garbage collector destroys the object.

HasFocusWithinCore()

Gets a value that indicates whether the sink or one of its contained components has focus.

MeasureOverride(Size)

Returns the size of the window represented by the HwndHost object, as requested by layout engine operations.

OnCreateAutomationPeer()

Creates an AutomationPeer for HwndHost .

OnDpiChanged(DpiScale, DpiScale)

Called when the DPI at which this HwndHost is rendered changes.

OnKeyDown(KeyEventArgs)

Called when the hosted window receives a WM_KEYDOWN message.

OnKeyUp(KeyEventArgs)

Called when the hosted window receives a WM_KEYUP message.

OnMnemonicCore(MSG, ModifierKeys)

Called when one of the mnemonics (access keys) for this sink is invoked.

OnWindowPositionChanged(Rect)

Called when the hosted window's position changes.

RegisterKeyboardInputSinkCore(IKeyboardInputSink)

Registers the IKeyboardInputSink interface of a contained component.

TabIntoCore(TraversalRequest)

Sets focus on either the first tab stop or the last tab stop of the sink.

TranslateAcceleratorCore(MSG, ModifierKeys)

Processes keyboard input at the keydown message level.

TranslateCharCore(MSG, ModifierKeys)

Processes WM_CHAR, WM_SYSCHAR, WM_DEADCHAR, and WM_SYSDEADCHAR input messages before the OnMnemonic(MSG, ModifierKeys) method is called.

UpdateWindowPos()

Updates the child window's size, visibility, and position to reflect the current state of the element.

WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean)

When overridden in a derived class, accesses the window process (handle) of the hosted child window.

Events

DpiChanged

Occurs after the DPI of the screen on which the HwndHost is displayed changes.

MessageHook

Occurs for each unhandled message that is received by the hosted window.

Explicit Interface Implementations

IKeyboardInputSink.HasFocusWithin()

For a description of this member, see System.Windows.Media.FamilyTypefaceCollection.System.

IKeyboardInputSink.KeyboardInputSite

For a description of this member, see KeyboardInputSite.

IKeyboardInputSink.OnMnemonic(MSG, ModifierKeys)

For a description of this member, see OnMnemonic(MSG, ModifierKeys).

IKeyboardInputSink.RegisterKeyboardInputSink(IKeyboardInputSink)

For a description of this member, see RegisterKeyboardInputSink(IKeyboardInputSink).

IKeyboardInputSink.TabInto(TraversalRequest)

For a description of this member, see TabInto(TraversalRequest).

IKeyboardInputSink.TranslateAccelerator(MSG, ModifierKeys)

For a description of this member, see TranslateAccelerator(MSG, ModifierKeys).

IKeyboardInputSink.TranslateChar(MSG, ModifierKeys)

For a description of this member, see TranslateChar(MSG, ModifierKeys).