Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
// This method will return the size of the complete desktop area, taking all attached devices into account.
public Size GetDesktopSize()
{
Rectangle desktop = new Rectangle();
DISPLAY_DEVICE device = new DISPLAY_DEVICE();
device.cb = System.Runtime.InteropServices.Marshal.SizeOf(typeof(DISPLAY_DEVICE));
device.DeviceName = new string(' ', 32);
device.DeviceString = new string(' ', 128);
device.DeviceKey = new string(' ', 128);
device.DeviceID = new string(' ', 128);
for(uint i = 0; ; i++)
{
if (!Win32.EnumDisplayDevices(null, i, ref device, 0))
break;
// If it's not connected to the desktop, then ignore it.
if ((device.StateFlags & 1) == 0)
continue;
// Get the settings of the current display mode for this device.
DEVMODE devMode = new DEVMODE();
if (!Win32.EnumDisplaySettings(device.DeviceName, uint.MaxValue, ref devMode))
continue;
// This is the rectangle defined by this device
Rectangle deviceRect = new Rectangle(devMode.dmPosition.x, devMode.dmPosition.y,
devMode.dmPelsWidth, devMode.dmPelsHeight);
// Update the "desktop" rectangle with the new device
if (desktop.Left > deviceRect.Left)
desktop.Location = new Point(deviceRect.Left, desktop.Y);
if (desktop.Top > deviceRect.Top)
desktop.Location = new Point(desktop.X, deviceRect.Top);
if (desktop.Right < deviceRect.Right)
desktop.Size = new Size(deviceRect.Width, desktop.Height);
if (desktop.Bottom < deviceRect.Bottom)
desktop.Size = new Size(desktop.Width, deviceRect.Height);
}
// And return the size of the total desktop.
return desktop.Size;
}
Alternative Managed API:
Do you know one? Please contribute it!
The EnumDisplayDevices API
12/16/2019 5:31:09 PM - -88.69.25.3
This structure defines various properties about a display device. It is used by the EnumDisplayDevices method.
8/7/2019 5:22:09 PM - -165.214.11.78
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).