Class Windows
Contains a set of helper methods for the Microsoft Windows API.
Inherited Members
Namespace: TheXDS.MCART.Helpers
Assembly: MCART.Windows.dll
Syntax
public static class Windows
Properties
| Edit this page View SourceInfo
Obtains an object that exposes varied information about Windows.
Declaration
public static WindowsInfo Info { get; }
Property Value
| Type | Description |
|---|---|
| WindowsInfo |
Methods
| Edit this page View SourceGetAeroAccentColor()
Gets the current Aero accent color of Windows.
Declaration
public static Color GetAeroAccentColor()
Returns
| Type | Description |
|---|---|
| Color | The current Aero accent color as a Color. |
GetConsoleWindow()
Obtains an object that allows controlling the console window.
Declaration
public static ConsoleWindow GetConsoleWindow()
Returns
| Type | Description |
|---|---|
| ConsoleWindow | An object that controls the console window. |
GetCursorPosition()
Gets the absolute cursor coordinates on the screen.
Declaration
public static Point GetCursorPosition()
Returns
| Type | Description |
|---|---|
| Point | A Point containing the cursor's absolute screen coordinates. |
GetDpi()
Gets the horizontal and vertical screen resolution in DPI.
Declaration
public static Size GetDpi()
Returns
| Type | Description |
|---|---|
| Size | A Size that indicates the screen resolution in Dots Per Inch (DPI). |
GetDpi(nint)
Gets the horizontal and vertical resolution of the window in DPI.
Declaration
public static Size GetDpi(nint hwnd)
Parameters
| Type | Name | Description |
|---|---|---|
| nint | hwnd | Window identifier to check. |
Returns
| Type | Description |
|---|---|
| Size | A Size that indicates the window resolution in Dots Per Inch (DPI). |
GetScalingFactor()
Obtains the GUI scaling factor.
Declaration
public static float GetScalingFactor()
Returns
| Type | Description |
|---|---|
| float | A float that represents the system GUI scaling factor. |
GetScalingFactor(IMsWindow)
Obtains the scaling factor of the specified window.
Declaration
public static float GetScalingFactor(this IMsWindow window)
Parameters
| Type | Name | Description |
|---|---|---|
| IMsWindow | window | Window to check. |
Returns
| Type | Description |
|---|---|
| float | A float representing the scaling factor used to draw the specified window. |
GetXDpi()
Obtains the horizontal screen resolution in DPI.
Declaration
public static int GetXDpi()
Returns
| Type | Description |
|---|---|
| int | An integer indicating the horizontal screen resolution in Dots Per Inch (DPI). |
GetXDpi(nint)
Gets the horizontal resolution of the window in DPI.
Declaration
public static int GetXDpi(nint hwnd)
Parameters
| Type | Name | Description |
|---|---|---|
| nint | hwnd | Window identifier to check. |
Returns
| Type | Description |
|---|---|
| int | An integer indicating the horizontal window resolution in Dots Per Inch (DPI). |
GetYDpi()
Gets the vertical screen resolution in DPI.
Declaration
public static int GetYDpi()
Returns
| Type | Description |
|---|---|
| int | An integer indicating the vertical screen resolution in Dots Per Inch (DPI). |
GetYDpi(nint)
Gets the vertical resolution of the window in DPI.
Declaration
public static int GetYDpi(nint hwnd)
Parameters
| Type | Name | Description |
|---|---|---|
| nint | hwnd | Window identifier to check. |
Returns
| Type | Description |
|---|---|
| int | An integer indicating the vertical window resolution in Dots Per Inch (DPI). |
IsAdministrator()
Checks whether the current execution context of the application contains administrative permissions.
Declaration
public static bool IsAdministrator()
Returns
| Type | Description |
|---|---|
| bool | true if the application runs with administrative privileges, otherwise false. |
IsCompositionEnabled()
Checks whether window composition is available on the system.
Declaration
public static bool IsCompositionEnabled()
Returns
| Type | Description |
|---|---|
| bool |
PickDrawingBrush()
Returns a randomly chosen drawing brush.
Declaration
public static Brush PickDrawingBrush()
Returns
| Type | Description |
|---|---|
| Brush | A Brush selected at random. |
ReleaseComObject(object)
Releases a COM object.
Declaration
public static void ReleaseComObject(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | COM object to release. |
TryAllocateConsole()
Opens a console for the application.
Declaration
public static bool TryAllocateConsole()
Returns
| Type | Description |
|---|---|
| bool | true if a console was successfully allocated, otherwise false. |
Remarks
This function is exclusive to Microsoft Windows® operating systems.
TryDeleteObject(nint)
Attempts to delete a Windows object by its specific handle.
Declaration
public static bool TryDeleteObject(nint hwnd)
Parameters
| Type | Name | Description |
|---|---|---|
| nint | hwnd | Handle of the Windows object to delete. |
Returns
| Type | Description |
|---|---|
| bool |
TryFreeConsole()
Frees the console of the application.
Declaration
public static bool TryFreeConsole()
Returns
| Type | Description |
|---|---|
| bool | true if the console was successfully freed, otherwise false. |
Remarks
This function is exclusive to Microsoft Windows® operating systems.