C# Class NanoByte.Common.Native.WinFormsUtils

Provides helper methods and API calls specific to the System.Windows.Forms UI toolkit.
Show file Open project: nano-byte/common

Public Methods

Method Description
CenterOnParent ( [ form ) : void

Centers a window on its parent/owner. Call this from the Form.Load event handler.

This method is an alternative to FormStartPosition.CenterParent which only works with Form.ShowDialog(IWin32Window) and not Form.Show(IWin32Window).

IsKeyDown ( Keys key ) : bool

Determines whether key is pressed right now.

Will always return false on non-Windows OSes.

RegisterTouchWindow ( Control control ) : void

Registers a control as a receiver for touch events.

ReleaseCapture ( ) : bool

Releases the mouse cursor after it was locked by SetCapture.

Will always return false on non-Windows OSes.

SetCapture ( IntPtr handle ) : IntPtr

Prevents the mouse cursor from leaving a specific window.

Will do nothing on non-Windows OSes.

Private Methods

Method Description
AddShieldIcon ( [ button ) : void
EnableWindowDrag ( [ control ) : void
HandleTouchMessage ( Message &m, object sender, EventHandler onTouchDown, EventHandler onTouchMove, EventHandler onTouchUp ) : void
SetForegroundWindow ( [ form ) : void

Method Details

CenterOnParent() public static method

Centers a window on its parent/owner. Call this from the Form.Load event handler.
This method is an alternative to FormStartPosition.CenterParent which only works with Form.ShowDialog(IWin32Window) and not Form.Show(IWin32Window).
public static CenterOnParent ( [ form ) : void
form [
return void

IsKeyDown() public static method

Determines whether key is pressed right now.
Will always return false on non-Windows OSes.
public static IsKeyDown ( Keys key ) : bool
key Keys
return bool

RegisterTouchWindow() public static method

Registers a control as a receiver for touch events.
public static RegisterTouchWindow ( Control control ) : void
control System.Windows.Forms.Control The control to register.
return void

ReleaseCapture() public static method

Releases the mouse cursor after it was locked by SetCapture.
Will always return false on non-Windows OSes.
public static ReleaseCapture ( ) : bool
return bool

SetCapture() public static method

Prevents the mouse cursor from leaving a specific window.
Will do nothing on non-Windows OSes.
public static SetCapture ( IntPtr handle ) : IntPtr
handle System.IntPtr The handle to the window to lock the mouse cursor into.
return System.IntPtr