Volume Control
Application-specific hotkeys for Windows
VolumeControl.WPF.WindowHandleGetter Class Reference

Helper object for C# Class Libraries being unable to get the current WPF window handle. More...

Collaboration diagram for VolumeControl.WPF.WindowHandleGetter:

Static Public Member Functions

static IntPtr GetWindowHandle (Window wnd)
 Gets the primary WPF window's handle.
This uses WindowInteropHelper.EnsureHandle to ensure that a valid handle is always returned at any point during initialization. More...
 
static IntPtr GetWindowHandle ()
 
static HwndSource GetHwndSource (IntPtr hWnd)
 Gets the HwndSource associated with the given Window Handle hWnd . More...
 

Detailed Description

Helper object for C# Class Libraries being unable to get the current WPF window handle.

This can be used to receive window messages for the current window even from within non-WPF projects.

Member Function Documentation

◆ GetHwndSource()

static HwndSource VolumeControl.WPF.WindowHandleGetter.GetHwndSource ( IntPtr  hWnd)
static

Gets the HwndSource associated with the given Window Handle hWnd .

Parameters
hWndThe IntPtr associated with a WPF window.
Returns
HwndSource that can be used to receive WPF window messages.

◆ GetWindowHandle() [1/2]

static IntPtr VolumeControl.WPF.WindowHandleGetter.GetWindowHandle ( )
static

Without parameters, this function uses the main window's handle using the Application.MainWindow property from Application.Current.

◆ GetWindowHandle() [2/2]

static IntPtr VolumeControl.WPF.WindowHandleGetter.GetWindowHandle ( Window  wnd)
static

Gets the primary WPF window's handle.
This uses WindowInteropHelper.EnsureHandle to ensure that a valid handle is always returned at any point during initialization.

Returns
IntPtr set to the current WPF window's handle.

The documentation for this class was generated from the following file: