Volume Control
Application-specific hotkeys for Windows
VolumeControl.Core.User32 Class Reference

Contains various functions from user32.dll More...

Collaboration diagram for VolumeControl.Core.User32:

Public Types

enum class  ECmdShow : int {
  SW_HIDE = 0 , SW_SHOWNORMAL = 1 , SW_SHOWMINIMIZED = 2 , SW_SHOWMAXIMIZED = 3 ,
  SW_SHOWNOACTIVATE = 4 , SW_SHOW = 5 , SW_MINIMIZE = 6 , SW_SHOWMINNOACTIVE = 7 ,
  SW_SHOWNA = 8 , SW_RESTORE = 9 , SW_SHOWDEFAULT = 10 , SW_FORCEMINIMIZE = 11
}
 Modes that define how a window shown by calling ShowWindow(IntPtr, int) acts.
This should be passed as the nCmdShow parameter. More...
 
enum class  EUFlags : uint {
  SWP_ASYNCWINDOWPOS = 0x4000 , SWP_DEFERERASE = 0x2000 , SWP_DRAWFRAME = 0x0020 , SWP_FRAMECHANGED = 0x0020 ,
  SWP_HIDEWINDOW = 0x0080 , SWP_NOACTIVATE = 0x0010 , SWP_NOCOPYBITS = 0x0100 , SWP_NOMOVE = 0x0002 ,
  SWP_NOOWNERZORDER = 0x0200 , SWP_NOREDRAW = 0x0008 , SWP_NOREPOSITION = 0x0200 , SWP_NOSENDCHANGING = 0x0400 ,
  SWP_NOSIZE = 0x0001 , SWP_NOZORDER = 0x0004 , SWP_SHOWWINDOW = 0x0040
}
 Possible values to pass to the SetWindowPos(IntPtr, IntPtr, int, int, int, int, EUFlags) function. More...
 

Public Member Functions

static bool SetWindowPos (IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags)
 Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order. More...
 
static bool SetActiveWindow (IntPtr hWnd)
 Activates a window. The window must be attached to the calling thread's message queue. More...
 
static bool ShowWindow (IntPtr hWnd, int nCmdShow)
 Sets the specified window's show state. More...
 

Static Public Member Functions

static bool SetWindowPos (IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, EUFlags eFlags)
 Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order. More...
 
static bool ShowWindow (IntPtr hWnd, ECmdShow eCmdShow)
 Sets the specified window's show state. More...
 
static void KeyboardEvent (EVirtualKeyCode vk)
 

Static Public Attributes

static readonly IntPtr HWND_BOTTOM = new(1)
 Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows. More...
 
static readonly IntPtr HWND_NOTOPMOST = new(-2)
 Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window. More...
 
static readonly IntPtr HWND_TOP = new(0)
 Places the window at the top of the Z order. More...
 
static readonly IntPtr HWND_TOPMOST = new(-1)
 Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated. More...
 

Detailed Description

Contains various functions from user32.dll

Member Enumeration Documentation

◆ ECmdShow

Modes that define how a window shown by calling ShowWindow(IntPtr, int) acts.
This should be passed as the nCmdShow parameter.

You can use ShowWindow(IntPtr, ECmdShow) as an alias for converting the enum value to an integer.

Enumerator
SW_HIDE 

Hides the window and activates another window.

SW_SHOWNORMAL 

Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

SW_SHOWMINIMIZED 

Activates the window and displays it as a minimized window.

SW_SHOWMAXIMIZED 

Activates the window and displays it as a maximized window.

SW_SHOWNOACTIVATE 

Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.

This is especially useful

SW_SHOW 

Activates the window and displays it in its current size and position.

SW_MINIMIZE 

Minimizes the specified window and activates the next top-level window in the Z order.

SW_SHOWMINNOACTIVE 

Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.

SW_SHOWNA 

Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated.

SW_RESTORE 

Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.

SW_SHOWDEFAULT 

Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.

SW_FORCEMINIMIZE 

Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.

◆ EUFlags

Possible values to pass to the SetWindowPos(IntPtr, IntPtr, int, int, int, int, EUFlags) function.

Enumerator
SWP_ASYNCWINDOWPOS 

If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.

SWP_DEFERERASE 

Prevents generation of the WM_SYNCPAINT message.

SWP_DRAWFRAME 

Draws a frame (defined in the window's class description) around the window.

SWP_FRAMECHANGED 

Applies new frame styles set using the SetWindowLong function.Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.

SWP_HIDEWINDOW 

Hides the window.

SWP_NOACTIVATE 

Does not activate the window.If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).

SWP_NOCOPYBITS 

Discards the entire contents of the client area.If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.

SWP_NOMOVE 

Retains the current position (ignores X and Y parameters).

SWP_NOOWNERZORDER 

Does not change the owner window's position in the Z order.

SWP_NOREDRAW 

Does not redraw changes.If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved.When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.

SWP_NOREPOSITION 

Same as the SWP_NOOWNERZORDER flag.

SWP_NOSENDCHANGING 

Prevents the window from receiving the WM_WINDOWPOSCHANGING message.

SWP_NOSIZE 

Retains the current size (ignores the cx and cy parameters).

SWP_NOZORDER 

Retains the current Z order (ignores the hWndInsertAfter parameter).

SWP_SHOWWINDOW 

Displays the window.

Member Function Documentation

◆ KeyboardEvent()

static void VolumeControl.Core.User32.KeyboardEvent ( EVirtualKeyCode  vk)
static
Parameters
vkThe EVirtualKeyCode of the key to 'press'.

◆ SetActiveWindow()

static bool VolumeControl.Core.User32.SetActiveWindow ( IntPtr  hWnd)

Activates a window. The window must be attached to the calling thread's message queue.

Parameters
hWndA handle to the top-level window to be activated.

The SetActiveWindow function activates a window, but not if the application is in the background. The window will be brought into the foreground (top of Z-Order) if its application is in the foreground when the system activates the window.
If the window identified by the hWnd parameter was created by the calling thread, the active window status of the calling thread is set to hWnd.Otherwise, the active window status of the calling thread is set to NULL.

Returns
If the function succeeds, the return value is the handle to the window that was previously active.
If the function fails, the return value is NULL.To get extended error information, call GetLastError.

◆ SetWindowPos() [1/2]

static bool VolumeControl.Core.User32.SetWindowPos ( IntPtr  hWnd,
IntPtr  hWndInsertAfter,
int  X,
int  Y,
int  cx,
int  cy,
EUFlags  eFlags 
)
static

Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

Parameters
hWndA handle to the window.
hWndInsertAfterA handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values. HWND_BOTTOM, HWND_NOTOPMOST, HWND_TOP, or HWND_TOPMOST.
XThe new position of the left side of the window, in client coordinates.
YThe new position of the top of the window, in client coordinates.
cxThe new width of the window, in pixels.
cyThe new height of the window, in pixels.
eFlagsThe window sizing and positioning flags of type EUFlags.
Returns
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.To get extended error information, call GetLastError.

◆ SetWindowPos() [2/2]

static bool VolumeControl.Core.User32.SetWindowPos ( IntPtr  hWnd,
IntPtr  hWndInsertAfter,
int  X,
int  Y,
int  cx,
int  cy,
uint  uFlags 
)

Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

Parameters
hWndA handle to the window.
hWndInsertAfterA handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values. HWND_BOTTOM, HWND_NOTOPMOST, HWND_TOP, or HWND_TOPMOST.
XThe new position of the left side of the window, in client coordinates.
YThe new position of the top of the window, in client coordinates.
cxThe new width of the window, in pixels.
cyThe new height of the window, in pixels.
uFlagsThe window sizing and positioning flags.
Returns
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.To get extended error information, call GetLastError.

◆ ShowWindow() [1/2]

static bool VolumeControl.Core.User32.ShowWindow ( IntPtr  hWnd,
ECmdShow  eCmdShow 
)
static

Sets the specified window's show state.

The first time this function is called, the eCmdShow parameter is ignored in order to initialize with hWnd .

Parameters
hWndA handle to the window.
This can be acquired with:
Form.Handle
eCmdShowControls how the window is to be shown.
Returns
trueIf the window was previously visible, the return value is nonzero.
falseIf the window was previously hidden, the return value is zero.

◆ ShowWindow() [2/2]

static bool VolumeControl.Core.User32.ShowWindow ( IntPtr  hWnd,
int  nCmdShow 
)

Sets the specified window's show state.

To perform certain special effects when showing or hiding a window, use AnimateWindow. The first time an application calls ShowWindow, it should use the WinMain function's nCmdShow parameter as its nCmdShow parameter. Subsequent calls to ShowWindow must use one of the values in the given list, instead of the one specified by the WinMain function's nCmdShow parameter. As noted in the discussion of the nCmdShow parameter, the nCmdShow value is ignored in the first call to ShowWindow if the program that launched the application specifies startup information in the structure.In this case, ShowWindow uses the information specified in the STARTUPINFO structure to show the window.On subsequent calls, the application must call ShowWindow with nCmdShow set to SW_SHOWDEFAULT to use the startup information provided by the program that launched the application.This behavior is designed for the following situations:

  • Applications create their main window by calling CreateWindow with the WS_VISIBLE flag set.
  • Applications create their main window by calling CreateWindow with the WS_VISIBLE flag cleared, and later call ShowWindow with the ECmdShow.SW_SHOW flag set to make it visible.
Parameters
hWndA handle to the window.
nCmdShowControls how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides a STARTUPINFO structure. Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter can be one of the following values.
Returns
trueIf the window was previously visible, the return value is nonzero.
falseIf the window was previously hidden, the return value is zero.

Member Data Documentation

◆ HWND_BOTTOM

readonly IntPtr VolumeControl.Core.User32.HWND_BOTTOM = new(1)
static

Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.

◆ HWND_NOTOPMOST

readonly IntPtr VolumeControl.Core.User32.HWND_NOTOPMOST = new(-2)
static

Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.

◆ HWND_TOP

readonly IntPtr VolumeControl.Core.User32.HWND_TOP = new(0)
static

Places the window at the top of the Z order.

◆ HWND_TOPMOST

readonly IntPtr VolumeControl.Core.User32.HWND_TOPMOST = new(-1)
static

Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.


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