NanoByte.Common  2.6.1
NanoByte.Common.Native.WinFormsUtils Class Reference

Provides helper methods and API calls specific to the System.Windows.Forms UI toolkit. More...

Static Public Member Functions

static void CenterOnParent (this Form form)
 Centers a window on its parent/owner. Call this from the Form.Load event handler. More...
 
static void SetForegroundWindow (this Form form)
 Forces a window to the foreground or flashes the taskbar if another process has the focus. More...
 
static void EnableWindowDrag (this Control control)
 Configures a control to move the entire window when clicked and dragged. More...
 
static void AddShieldIcon (this Button button)
 Adds a UAC shield icon to a button. Does nothing if not running Windows Vista or newer. More...
 
static bool IsKeyDown (Keys key)
 Determines whether key is pressed right now. More...
 
static IntPtr SetCapture (IntPtr handle)
 Prevents the mouse cursor from leaving a specific window. More...
 
static bool ReleaseCapture ()
 Releases the mouse cursor after it was locked by SetCapture. More...
 
static void RegisterTouchWindow (Control control)
 Registers a control as a receiver for touch events. More...
 
static void HandleTouchMessage (ref Message m, object? sender, EventHandler< TouchEventArgs >? onTouchDown, EventHandler< TouchEventArgs >? onTouchMove, EventHandler< TouchEventArgs >? onTouchUp)
 Handles touch-related Control.WndProc Messages. More...
 

Properties

static bool AppIdle [get]
 Determines whether this application is currently idle. More...
 
static float CaretBlinkTime [get]
 Text-box caret blink time in seconds. More...
 

Detailed Description

Provides helper methods and API calls specific to the System.Windows.Forms UI toolkit.

Member Function Documentation

◆ AddShieldIcon()

static void NanoByte.Common.Native.WinFormsUtils.AddShieldIcon ( this Button  button)
inlinestatic

Adds a UAC shield icon to a button. Does nothing if not running Windows Vista or newer.

This is purely cosmetic. UAC elevation is a separate concern.

◆ CenterOnParent()

static void NanoByte.Common.Native.WinFormsUtils.CenterOnParent ( this Form  form)
inlinestatic

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).

◆ EnableWindowDrag()

static void NanoByte.Common.Native.WinFormsUtils.EnableWindowDrag ( this Control  control)
inlinestatic

Configures a control to move the entire window when clicked and dragged.

◆ HandleTouchMessage()

static void NanoByte.Common.Native.WinFormsUtils.HandleTouchMessage ( ref Message  m,
object?  sender,
EventHandler< TouchEventArgs >?  onTouchDown,
EventHandler< TouchEventArgs >?  onTouchMove,
EventHandler< TouchEventArgs >?  onTouchUp 
)
inlinestatic

Handles touch-related Control.WndProc Messages.

Parameters
mThe message to handle.
senderThe object to send possible events from.
onTouchDownThe event handler to call for touch down events; can be null.
onTouchMoveThe event handler to call for touch move events; can be null.
onTouchUpThe event handler to call for touch up events; can be null.

◆ IsKeyDown()

static bool NanoByte.Common.Native.WinFormsUtils.IsKeyDown ( Keys  key)
inlinestatic

Determines whether key is pressed right now.

Will always return false on non-Windows OSes.

◆ RegisterTouchWindow()

static void NanoByte.Common.Native.WinFormsUtils.RegisterTouchWindow ( Control  control)
inlinestatic

Registers a control as a receiver for touch events.

Parameters
controlThe control to register.

◆ ReleaseCapture()

static bool NanoByte.Common.Native.WinFormsUtils.ReleaseCapture ( )
inlinestatic

Releases the mouse cursor after it was locked by SetCapture.

Returns
true if successful; false otherwise.

Will always return false on non-Windows OSes.

◆ SetCapture()

static IntPtr NanoByte.Common.Native.WinFormsUtils.SetCapture ( IntPtr  handle)
inlinestatic

Prevents the mouse cursor from leaving a specific window.

Parameters
handleThe handle to the window to lock the mouse cursor into.
Returns
A handle to the window that had previously captured the mouse.

Will do nothing on non-Windows OSes.

◆ SetForegroundWindow()

static void NanoByte.Common.Native.WinFormsUtils.SetForegroundWindow ( this Form  form)
inlinestatic

Forces a window to the foreground or flashes the taskbar if another process has the focus.

Property Documentation

◆ AppIdle

bool NanoByte.Common.Native.WinFormsUtils.AppIdle
staticget

Determines whether this application is currently idle.

Returns
true if idle, false if handling window events.

Will always return true on non-Windows OSes.

◆ CaretBlinkTime

float NanoByte.Common.Native.WinFormsUtils.CaretBlinkTime
staticget

Text-box caret blink time in seconds.


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