C# Class PInvoke.User32

Mostrar archivo Open project: AArnott/pinvoke Class Usage Examples

Public Properties

Property Type Description
HBMMENU_CALLBACK System.IntPtr
HBMMENU_MBAR_CLOSE System.IntPtr
HBMMENU_MBAR_CLOSE_D System.IntPtr
HBMMENU_MBAR_MINIMIZE System.IntPtr
HBMMENU_MBAR_MINIMIZE_D System.IntPtr
HBMMENU_MBAR_RESTORE System.IntPtr
HBMMENU_POPUP_CLOSE System.IntPtr
HBMMENU_POPUP_MAXIMIZE System.IntPtr
HBMMENU_POPUP_MINIMIZE System.IntPtr
HBMMENU_POPUP_RESTORE System.IntPtr
HBMMENU_SYSTEM System.IntPtr
HWND_BROADCAST System.IntPtr

Public Methods

Method Description
BeginPaint ( IntPtr hwnd, [ lpPaint ) : SafeDCHandle

The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information about the painting.

The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving, creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing, BeginPaint sends a WindowMessage.WM_ERASEBKGND message to the window.

An application should not call BeginPaint except in response to a WindowMessage.WM_PAINT message. Each call to BeginPaint must have a corresponding call to the EndPaint(IntPtr, PAINTSTRUCT*) function.

If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased. If the window's class has a background brush, BeginPaint uses that brush to erase the background of the update region before returning.

CreateWindow ( string lpClassName, string lpWindowName, WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, void lpParam ) : IntPtr

The CreateWindow is identical to the CreateWindowEx function, actually it is a macro on C/C++

GetClassName ( IntPtr hWnd, int maxLength = 256 ) : string

Retrieves the name of the class to which the specified window belongs.

The suggested class name length is 256 as we didn't find any reference of class name length limits

GetClipboardFormatName ( int format ) : string

Retrieves from the clipboard the name of the specified registered format.

GetCursorPos ( ) : PInvoke.POINT

Retrieves the position of the mouse cursor, in screen coordinates.

GetDC ( IntPtr hWnd ) : SafeDCHandle

The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI. The GetDCEx function is an extension to GetDC, which gives an application more control over how and whether clipping occurs in the client area.

GetDCEx ( IntPtr hWnd, IntPtr hrgnClip, DeviceContextValues flags ) : SafeDCHandle

The GetDCEx function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI. This function is an extension to the GetDC function, which gives an application more control over how and whether clipping occurs in the client area.

Unless the display DC belongs to a window class, the ReleaseDC function must be called to release the DC after painting. Also, ReleaseDC must be called from the same thread that called GetDCEx. The number of DCs is limited only by available memory.

The function returns a handle to a DC that belongs to the window's class if CS_CLASSDC, CS_OWNDC or CS_PARENTDC was specified as a style in the WNDCLASS structure when the class was registered.

GetWindowDC ( IntPtr hWnd ) : SafeDCHandle

The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area. GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous attributes are lost.

GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any window is not recommended.

The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title bar, menu, and scroll bars. The GetDC function can be used to retrieve a device context for the entire screen. After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device context has serious effects on painting requested by applications.

GetWindowPlacement ( IntPtr hWnd ) : WINDOWPLACEMENT

Retrieves the show state and the restored, minimized, and maximized positions of the specified window.

GetWindowText ( IntPtr hWnd ) : string

Get the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is returned. However, GetWindowText cannot retrieve the text of a control in another application.

Private Methods

Method Description
AppendMenu ( IntPtr hMenu, MenuItemFlags uFlags, IntPtr uIdNewItem, string lpNewItem ) : bool
BeginPaint_IntPtr ( IntPtr hwnd, [ lpPaint ) : IntPtr
CallNextHookEx ( IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam ) : int
ChildWindowFromPoint ( IntPtr hWndParent, PInvoke.POINT Point ) : IntPtr
ChildWindowFromPointEx ( IntPtr hWndParent, PInvoke.POINT pt, ChildWindowFromPointExFlags uFlags ) : IntPtr
ClientToScreen ( IntPtr hWnd, PInvoke.POINT &lpPoint ) : bool
CloseClipboard ( ) : bool
CloseDesktop ( IntPtr hDesktop ) : bool
CloseWindowStation ( IntPtr hWinsta ) : bool
CreateDesktop ( string lpszDesktop, string lpszDevice, IntPtr pDevmode, DesktopCreationFlags dwFlags, ACCESS_MASK dwDesiredAccess, [ lpsa ) : SafeDesktopHandle
CreateDesktopEx ( string lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, DesktopCreationFlags dwFlags, ACCESS_MASK dwDesiredAccess, [ lpsa, uint ulHeapSize, IntPtr pvoid = default(IntPtr) ) : SafeDesktopHandle
CreateDialogIndirectParam ( SafeLibraryHandle hInstance, DLGTEMPLATE lpTemplate, IntPtr hWndParent, DialogProc lpDialogFunc, IntPtr lParamInit ) : IntPtr
CreateWindowEx ( WindowStylesEx dwExStyle, string lpClassName, string lpWindowName, WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, void lpParam ) : IntPtr
CreateWindowStation ( string lpwinsta, WindowStationCreationFlags dwFlags, ACCESS_MASK dwDesiredAccess, [ lpsa ) : SafeWindowStationHandle
DefWindowProc ( IntPtr hWnd, WindowMessage Msg, IntPtr wParam, IntPtr lParam ) : IntPtr
DispatchMessage ( MSG lpMsg ) : IntPtr
DrawText ( SafeDCHandle hDC, [ lpString, int nCount, [ lpRect, TextFormats uFormat ) : int
DrawTextEx ( SafeDCHandle hdc, [ lpchText, int cchText, [ lprc, uint dwDTFormat, [ lpDTParams ) : int
EmptyClipboard ( ) : bool
EndPaint ( IntPtr hWnd, [ lpPaint ) : bool
EnumDesktopWindows ( SafeDesktopHandle hDesktop, WNDENUMPROC lpfn, IntPtr lParam ) : bool
EnumDesktops ( SafeWindowStationHandle hWinsta, DESKTOPENUMPROC lpEnumFunc, IntPtr lParam ) : int
EnumDisplayMonitors ( IntPtr hdc, RECT lprcClip, MONITORENUMPROC lpfnEnum, void dwData ) : bool
EnumWindowStations ( WINSTAENUMPROC lpEnumFunc, IntPtr lParam ) : bool
EnumWindows ( WNDENUMPROC lpEnumFunc, IntPtr lParam ) : bool
FindWindow ( string lpClassName, string lpWindowName ) : IntPtr
FindWindowEx ( IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle ) : IntPtr
FlashWindowEx ( FLASHWINFO &pwfi ) : bool
GetActiveWindow ( ) : IntPtr
GetAncestor ( IntPtr hWnd, GetAncestorFlags gaFlags ) : IntPtr
GetAsyncKeyState ( VirtualKey vKey ) : short
GetClassInfoEx ( IntPtr hInstance, string lpClassName, WNDCLASSEX &lpWndClass ) : bool
GetClassName ( IntPtr hWnd, [ lpClassName, int nMaxCount ) : int
GetClientRect ( IntPtr hWnd, RECT &lpRect ) : bool
GetClipboardData ( int uFormat ) : void*
GetClipboardFormatName ( int format, [ lpszFormatName, int cchMaxCount ) : int
GetCursorPos ( PInvoke.POINT &lpPoint ) : bool
GetDCEx_IntPtr ( IntPtr hWnd, IntPtr hrgnClip, DeviceContextValues flags ) : IntPtr
GetDC_IntPtr ( IntPtr hWnd ) : IntPtr
GetDesktopWindow ( ) : IntPtr
GetForegroundWindow ( ) : IntPtr
GetKeyState ( VirtualKey vKey ) : short
GetMenuItemInfo ( IntPtr hMenu, uint uItem, [ fByPosition, MENUITEMINFO &lpmii ) : bool
GetMessage ( MSG lpMsg, IntPtr hWnd, WindowMessage wMsgFilterMin, WindowMessage wMsgFilterMax ) : int
GetMonitorInfo ( IntPtr hMonitor, [ lpmi ) : bool
GetMonitorInfoEx ( IntPtr hMonitor, [ lpmi ) : bool
GetProcessWindowStation ( ) : SafeWindowStationHandle
GetQueueStatus ( QueueStatusFlags flags ) : int
GetShellWindow ( ) : IntPtr
GetSystemMenu ( IntPtr hWnd, [ bRevert ) : IntPtr
GetSystemMetrics ( SystemMetric smIndex ) : int
GetThreadDesktop ( uint dwThreadId ) : SafeDesktopHandle
GetUserObjectInformation ( IntPtr hObj, ObjectInformationType nIndex, void pvInfo, uint nLength, uint lpnLengthNeeded ) : bool
GetWindowDC_IntPtr ( IntPtr hWnd ) : IntPtr
GetWindowDisplayAffinity ( IntPtr hWnd, int &dwAffinity ) : bool
GetWindowInfo ( IntPtr hwnd, WINDOWINFO &pwi ) : bool
GetWindowLong ( IntPtr hWnd, WindowLongIndexFlags nIndex ) : int
GetWindowPlacement ( IntPtr hWnd, WINDOWPLACEMENT lpwndpl ) : bool
GetWindowRect ( IntPtr hWnd, RECT &lpRect ) : bool
GetWindowText ( IntPtr hWnd, [ lpString, int nMaxCount ) : int
GetWindowTextLength ( IntPtr hWnd ) : int
GetWindowThreadProcessId ( IntPtr hWnd, int &lpdwProcessId ) : int
IsChild ( IntPtr hWndParent, IntPtr hWnd ) : bool
IsDialogMessage ( IntPtr hDlg, MSG lpMsg ) : bool
IsGUIThread ( [ bConvert ) : HResult
IsHungAppWindow ( IntPtr hWnd ) : bool
IsIconic ( IntPtr hWnd ) : bool
IsProcessDPIAware ( ) : bool
IsWindow ( IntPtr hWnd ) : bool
IsWindowUnicode ( IntPtr hWnd ) : bool
IsWindowVisible ( IntPtr hWnd ) : bool
IsZoomed ( IntPtr hWnd ) : bool
LoadCursor ( IntPtr hInstance, IntPtr lpCursorName ) : IntPtr
LoadIcon ( IntPtr hInstance, IntPtr lpIconName ) : IntPtr
LoadIcon ( IntPtr hInstance, string lpIconName ) : IntPtr
LoadString ( IntPtr hInstance, uint uID, char &lpBuffer, int cchBufferMax ) : int
LogicalToPhysicalPoint ( IntPtr hwnd, PInvoke.POINT &lpPoint ) : bool
LogicalToPhysicalPointForPerMonitorDPI ( IntPtr hwnd, PInvoke.POINT &lpPoint ) : bool
LookupIconIdFromDirectory ( byte presbits, [ fIcon ) : int
LookupIconIdFromDirectoryEx ( byte presbits, [ fIcon, int cxDesired, int cyDesired, LookupIconIdFromDirectoryExFlags Flags ) : int
MapVirtualKey ( int uCode, MapVirtualKeyTranslation uMapType ) : int
MapWindowPoints ( IntPtr hWndFrom, IntPtr hWndTo, RECT &rect, [ cPoints ) : int
MessageBeep ( MessageBeepType uType ) : bool
MessageBox ( IntPtr hWnd, string text, string caption, MessageBoxOptions options ) : MessageBoxResult
MessageBoxIndirect ( MSGBOXPARAMS &lpMsgBoxParams ) : int
MonitorFromPoint ( PInvoke.POINT pt, MonitorOptions dwFlags ) : IntPtr
MonitorFromPoint ( PInvoke.POINT point, int flags ) : IntPtr
MonitorFromRect ( RECT &lprc, MonitorOptions dwFlags ) : IntPtr
MonitorFromWindow ( IntPtr hwnd, MonitorOptions dwFlags ) : IntPtr
MoveWindow ( IntPtr hWnd, int X, int Y, int nWidth, int nHeight, [ bRepaint ) : bool
OpenClipboard ( IntPtr hWndNewOwner ) : bool
OpenDesktop ( string lpszDesktop, DesktopCreationFlags dwFlags, [ fInherit, ACCESS_MASK dwDesiredAccess ) : SafeDesktopHandle
OpenInputDesktop ( DesktopCreationFlags dwFlags, [ fInherit, ACCESS_MASK dwDesiredAccess ) : SafeDesktopHandle
OpenWindowStation ( string lpszWinSta, [ fInherit, ACCESS_MASK dwDesiredAccess ) : SafeWindowStationHandle
PeekMessage ( MSG lpMsg, IntPtr hWnd, WindowMessage wMsgFilterMin, WindowMessage wMsgFilterMax, PeekMessageRemoveFlags wRemoveMsg ) : bool
PhysicalToLogicalPoint ( IntPtr hwnd, PInvoke.POINT &lpPoint ) : bool
PhysicalToLogicalPointForPerMonitorDPI ( IntPtr hwnd, PInvoke.POINT &lpPoint ) : bool
PostMessage ( IntPtr hWnd, WindowMessage wMsg, void wParam, void lParam ) : bool
PostQuitMessage ( int nExitCode ) : void
PostThreadMessage ( int idThread, WindowMessage Msg, IntPtr wParam, IntPtr lParam ) : bool
PrintWindow ( IntPtr hWnd, IntPtr hdcBlt, PrintWindowFlags nFlags ) : bool
QueryDisplayConfig ( uint Flags, int &pNumPathArrayElements, [ pPathInfoArray, int &pNumModeInfoArrayElements, [ pModeInfoArray, [ pCurrentTopologyId ) : int
RealChildWindowFromPoint ( IntPtr hwndParent, PInvoke.POINT ptParentClientCoords ) : IntPtr
RealGetWindowClass ( IntPtr hwnd, [ pszType, uint cchType ) : uint
RegisterClass ( WNDCLASS &lpWndClass ) : ushort
RegisterClassEx ( WNDCLASSEX &lpwcx ) : short
RegisterWindowMessage ( string lpString ) : int
ReleaseCapture ( ) : bool
ReleaseDC ( IntPtr hWnd, IntPtr hDC ) : int
ScreenToClient ( IntPtr hWnd, PInvoke.POINT &lpPoint ) : bool
SendInput ( int nInputs, [ pInputs, int cbSize ) : uint
SendMessage ( IntPtr hWnd, WindowMessage wMsg, void wParam, void lParam ) : IntPtr
SetCapture ( IntPtr hWnd ) : IntPtr
SetClipboardData ( int uFormat, void hMem ) : void*
SetCursorPos ( int X, int Y ) : bool
SetForegroundWindow ( IntPtr hWnd ) : bool
SetMenuItemInfo ( IntPtr hMenu, uint uItem, [ fByPosition, [ lpmii ) : bool
SetParent ( IntPtr hWndChild, IntPtr hWndNewParent ) : IntPtr
SetProcessDPIAware ( ) : bool
SetProcessWindowStation ( SafeWindowStationHandle hWinSta ) : bool
SetThreadDesktop ( SafeDesktopHandle hDesktop ) : bool
SetWinEventHook ( WindowsEventHookType eventMin, WindowsEventHookType eventMax, IntPtr hmodWinEventProc, IntPtr lpfnWinEventProc, int idProcess, int idThread, WindowsEventHookFlags dwflags ) : SafeEventHookHandle
SetWinEventHook ( WindowsEventHookType eventMin, WindowsEventHookType eventMax, IntPtr hmodWinEventProc, WinEventProc lpfnWinEventProc, int idProcess, int idThread, WindowsEventHookFlags dwflags ) : SafeEventHookHandle
SetWindowDisplayAffinity ( IntPtr hWnd, int dwAffinity ) : bool
SetWindowLong ( IntPtr hWnd, WindowLongIndexFlags nIndex, SetWindowLongFlags dwNewLong ) : int
SetWindowPlacement ( IntPtr hWnd, [ lpwndpl ) : bool
SetWindowPos ( IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags ) : bool
SetWindowsHookEx ( WindowsHookType idHook, IntPtr lpfn, IntPtr hMod, int dwThreadId ) : SafeHookHandle
SetWindowsHookEx ( WindowsHookType idHook, WindowsHookDelegate lpfn, IntPtr hMod, int dwThreadId ) : SafeHookHandle
ShowWindow ( IntPtr hWnd, WindowShowStyle nCmdShow ) : bool
SwitchDesktop ( SafeDesktopHandle hDesktop ) : bool
SystemParametersInfo ( SystemParametersInfoAction uiAction, uint uiParam, void pvParam, SystemParametersInfoFlags fWinIni ) : bool
TranslateMessage ( MSG lpMsg ) : bool
UnhookWinEvent ( IntPtr hWinEventHook ) : bool
UnhookWindowsHookEx ( IntPtr hhk ) : bool
UpdateWindow ( IntPtr hWnd ) : bool
WaitForInputIdle ( IntPtr hProcess, int dwMilliseconds ) : int
WindowFromPhysicalPoint ( PInvoke.POINT pt ) : IntPtr
WindowFromPoint ( PInvoke.POINT Point ) : IntPtr
keybd_event ( byte bVk, byte bScan, KEYEVENTF dwFlags, void dwExtraInfo ) : void

Method Details

BeginPaint() public static method

The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information about the painting.

The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving, creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing, BeginPaint sends a WindowMessage.WM_ERASEBKGND message to the window.

An application should not call BeginPaint except in response to a WindowMessage.WM_PAINT message. Each call to BeginPaint must have a corresponding call to the EndPaint(IntPtr, PAINTSTRUCT*) function.

If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased. If the window's class has a background brush, BeginPaint uses that brush to erase the background of the update region before returning.

public static BeginPaint ( IntPtr hwnd, [ lpPaint ) : SafeDCHandle
hwnd System.IntPtr Handle to the window to be repainted.
lpPaint [ Pointer to the structure that will receive painting information.
return SafeDCHandle

CreateWindow() public static method

The CreateWindow is identical to the CreateWindowEx function, actually it is a macro on C/C++
public static CreateWindow ( string lpClassName, string lpWindowName, WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, void lpParam ) : IntPtr
lpClassName string /// Pointer to a null-terminated string or a class atom created by a previous call to the /// RegisterClass or RegisterClassEx function. The atom must be in the low-order word of /// lpClassName; the high-order word must be zero. If lpClassName is a string, it specifies /// the window class name. The class name can be any name registered with RegisterClass or /// RegisterClassEx, provided that the module that registers the class is also the module /// that creates the window. The class name can also be any of the predefined system class names. ///
lpWindowName string /// Pointer to a null-terminated string that specifies the window name. If the window style /// specifies a title bar, the window title pointed to by lpWindowName is displayed in the /// title bar. When using CreateWindow to create controls, such as buttons, check boxes, and /// static controls, use lpWindowName to specify the text of the control. When creating a /// static control with the SS_ICON style, use lpWindowName to specify the icon name or /// identifier. To specify an identifier, use the syntax "#num". ///
dwStyle WindowStyles /// Specifies the style of the window being created. This parameter can be a combination of /// window styles, plus the control styles indicated in the Remarks section. ///
x int /// Specifies the initial horizontal position of the window. For an overlapped or pop-up /// window, the x parameter is the initial x-coordinate of the window's upper-left corner, in /// screen coordinates. For a child window, x is the x-coordinate of the upper-left corner of /// the window relative to the upper-left corner of the parent window's client area. If x is /// set to CW_USEDEFAULT, the system selects the default position for the window's upper-left /// corner and ignores the y parameter. CW_USEDEFAULT is valid only for overlapped windows; /// if it is specified for a pop-up or child window, the x and y parameters are set to zero. ///
y int /// Specifies the initial vertical position of the window. For an overlapped or pop-up /// window, the y parameter is the initial y-coordinate of the window's upper-left corner, in /// screen coordinates. For a child window, y is the initial y-coordinate of the upper-left /// corner of the child window relative to the upper-left corner of the parent window's /// client area. For a list box y is the initial y-coordinate of the upper-left corner of the /// list box's client area relative to the upper-left corner of the parent window's client area. /// /// If an overlapped window is created with the WS_VISIBLE style bit set and the x parameter /// is set to CW_USEDEFAULT, then the y parameter determines how the window is shown. If the /// y parameter is CW_USEDEFAULT, then the window manager calls ShowWindow with the SW_SHOW /// flag after the window has been created. If the y parameter is some other value, then the /// window manager calls ShowWindow with that value as the nCmdShow parameter. /// ///
nWidth int /// Specifies the width, in device units, of the window. For overlapped windows, nWidth is /// the window's width, in screen coordinates, or CW_USEDEFAULT. If nWidth is CW_USEDEFAULT, /// the system selects a default width and height for the window; the default width extends /// from the initial x-coordinates to the right edge of the screen; the default height /// extends from the initial y-coordinate to the top of the icon area. CW_USEDEFAULT is valid /// only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, /// the nWidth and nHeight parameter are set to zero. ///
nHeight int /// Specifies the height, in device units, of the window. For overlapped windows, nHeight is /// the window's height, in screen coordinates. If the nWidth parameter is set to /// CW_USEDEFAULT, the system ignores nHeight. ///
hWndParent System.IntPtr /// Handle to the parent or owner window of the window being created. To create a child /// window or an owned window, supply a valid window handle. This parameter is optional for /// pop-up windows. /// /// Windows 2000/XP: To create a message-only window, supply HWND_MESSAGE or a handle to an /// existing message-only window. /// ///
hMenu System.IntPtr /// Handle to a menu, or specifies a child-window identifier, depending on the window style. /// For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; /// it can be NULL if the class menu is to be used. For a child window, hMenu specifies the /// child-window identifier, an integer value used by a dialog box control to notify its /// parent about events. The application determines the child-window identifier; it must be /// unique for all child windows with the same parent window. ///
hInstance System.IntPtr /// Handle to the instance of the module to be associated with the window. ///
lpParam void /// Pointer to a value to be passed to the window through the CREATESTRUCT structure /// (lpCreateParams member) pointed to by the lParam param of the WM_CREATE message. This /// message is sent to the created window by this function before it returns. /// /// If an application calls CreateWindow to create a MDI client window, lpParam should point /// to a CLIENTCREATESTRUCT structure. If an MDI client window calls CreateWindow to create /// an MDI child window, lpParam should point to a MDICREATESTRUCT structure. lpParam may be /// NULL if no additional data is needed. /// ///
return System.IntPtr

GetClassName() public static method

Retrieves the name of the class to which the specified window belongs.
The suggested class name length is 256 as we didn't find any reference of class name length limits
Thrown when an error occurs.
public static GetClassName ( IntPtr hWnd, int maxLength = 256 ) : string
hWnd System.IntPtr A handle to the window and, indirectly, the class to which the window belongs.
maxLength int The size of the string to return
return string

GetClipboardFormatName() public static method

Retrieves from the clipboard the name of the specified registered format.
Thrown when an error occurs.
public static GetClipboardFormatName ( int format ) : string
format int The type of format to be retrieved. This parameter must not specify any of the predefined clipboard formats.
return string

GetCursorPos() public static method

Retrieves the position of the mouse cursor, in screen coordinates.
public static GetCursorPos ( ) : PInvoke.POINT
return PInvoke.POINT

GetDC() public static method

The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI. The GetDCEx function is an extension to GetDC, which gives an application more control over how and whether clipping occurs in the client area.
public static GetDC ( IntPtr hWnd ) : SafeDCHandle
hWnd System.IntPtr A handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.
return SafeDCHandle

GetDCEx() public static method

The GetDCEx function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI. This function is an extension to the GetDC function, which gives an application more control over how and whether clipping occurs in the client area.

Unless the display DC belongs to a window class, the ReleaseDC function must be called to release the DC after painting. Also, ReleaseDC must be called from the same thread that called GetDCEx. The number of DCs is limited only by available memory.

The function returns a handle to a DC that belongs to the window's class if CS_CLASSDC, CS_OWNDC or CS_PARENTDC was specified as a style in the WNDCLASS structure when the class was registered.

public static GetDCEx ( IntPtr hWnd, IntPtr hrgnClip, DeviceContextValues flags ) : SafeDCHandle
hWnd System.IntPtr A handle to the window whose DC is to be retrieved. If this value is , GetDCEx retrieves the DC for the entire screen.
hrgnClip System.IntPtr /// A clipping region that may be combined with the visible region of the DC. /// If the value of flags is or , /// then the operating system assumes ownership of the region and will automatically delete it when it is no longer needed. /// In this case, the application should not use or delete the region after a successful call to GetDCEx.
flags DeviceContextValues Specifies how the DC is created.
return SafeDCHandle

GetWindowDC() public static method

The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area. GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous attributes are lost.

GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any window is not recommended.

The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title bar, menu, and scroll bars. The GetDC function can be used to retrieve a device context for the entire screen. After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device context has serious effects on painting requested by applications.

public static GetWindowDC ( IntPtr hWnd ) : SafeDCHandle
hWnd System.IntPtr /// A handle to the window with a device context that is to be retrieved. If this value is , GetWindowDC retrieves the device context for the entire screen. /// If this parameter is , GetWindowDC retrieves the device context for the primary display monitor. /// To get the device context for other display monitors, use the and CreateDC functions.
return SafeDCHandle

GetWindowPlacement() public static method

Retrieves the show state and the restored, minimized, and maximized positions of the specified window.
public static GetWindowPlacement ( IntPtr hWnd ) : WINDOWPLACEMENT
hWnd System.IntPtr A handle to the window.
return WINDOWPLACEMENT

GetWindowText() public static method

Get the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is returned. However, GetWindowText cannot retrieve the text of a control in another application.
public static GetWindowText ( IntPtr hWnd ) : string
hWnd System.IntPtr A handle to the window or control containing the text.
return string

Property Details

HBMMENU_CALLBACK public_oe static_oe property

A bitmap that is drawn by the window that owns the menu. The application must process the WM_MEASUREITEM and WM_DRAWITEM messages.
public static IntPtr,System HBMMENU_CALLBACK
return System.IntPtr

HBMMENU_MBAR_CLOSE public_oe static_oe property

Close button for the menu bar.
public static IntPtr,System HBMMENU_MBAR_CLOSE
return System.IntPtr

HBMMENU_MBAR_CLOSE_D public_oe static_oe property

Disabled close button for the menu bar.
public static IntPtr,System HBMMENU_MBAR_CLOSE_D
return System.IntPtr

HBMMENU_MBAR_MINIMIZE public_oe static_oe property

Minimize button for the menu bar.
public static IntPtr,System HBMMENU_MBAR_MINIMIZE
return System.IntPtr

HBMMENU_MBAR_MINIMIZE_D public_oe static_oe property

Disabled minimize button for the menu bar.
public static IntPtr,System HBMMENU_MBAR_MINIMIZE_D
return System.IntPtr

HBMMENU_MBAR_RESTORE public_oe static_oe property

Restore button for the menu bar.
public static IntPtr,System HBMMENU_MBAR_RESTORE
return System.IntPtr

HBMMENU_POPUP_CLOSE public_oe static_oe property

Close button for the submenu.
public static IntPtr,System HBMMENU_POPUP_CLOSE
return System.IntPtr

HBMMENU_POPUP_MAXIMIZE public_oe static_oe property

Maximize button for the submenu.
public static IntPtr,System HBMMENU_POPUP_MAXIMIZE
return System.IntPtr

HBMMENU_POPUP_MINIMIZE public_oe static_oe property

Minimize button for the submenu.
public static IntPtr,System HBMMENU_POPUP_MINIMIZE
return System.IntPtr

HBMMENU_POPUP_RESTORE public_oe static_oe property

Restore button for the submenu.
public static IntPtr,System HBMMENU_POPUP_RESTORE
return System.IntPtr

HBMMENU_SYSTEM public_oe static_oe property

Windows icon or the icon of the window specified in MENUITEMINFO.dwItemData.
public static IntPtr,System HBMMENU_SYSTEM
return System.IntPtr

HWND_BROADCAST public_oe static_oe property

A special windows handle used to indicate to SendMessage(IntPtr, WindowMessage, IntPtr, IntPtr) that the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows.
public static IntPtr,System HWND_BROADCAST
return System.IntPtr