mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 08:34:55 +00:00
a10a5ef897
Get monitor info based on handle (hwnd). It's unclear if the coordinates need to be dpi scaled, revisit later if they do
55 lines
2.3 KiB
C#
55 lines
2.3 KiB
C#
// Copyright © 2018 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace CefSharp.Wpf.Internals
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
internal struct MonitorInfoEx
|
|
{
|
|
private const int CCHDEVICENAME = 32;
|
|
/// <summary>
|
|
/// The size, in bytes, of the structure. Set this member to sizeof(MONITORINFOEX) (72) before calling the GetMonitorInfo function.
|
|
/// Doing so lets the function determine the type of structure you are passing to it.
|
|
/// </summary>
|
|
public int Size;
|
|
|
|
/// <summary>
|
|
/// A RECT structure that specifies the display monitor rectangle, expressed in virtual-screen coordinates.
|
|
/// Note that if the monitor is not the primary display monitor, some of the rectangle's coordinates may be negative values.
|
|
/// </summary>
|
|
public RectStruct Monitor;
|
|
|
|
/// <summary>
|
|
/// A RECT structure that specifies the work area rectangle of the display monitor that can be used by applications,
|
|
/// expressed in virtual-screen coordinates. Windows uses this rectangle to maximize an application on the monitor.
|
|
/// The rest of the area in rcMonitor contains system windows such as the task bar and side bars.
|
|
/// Note that if the monitor is not the primary display monitor, some of the rectangle's coordinates may be negative values.
|
|
/// </summary>
|
|
public RectStruct WorkArea;
|
|
|
|
/// <summary>
|
|
/// The attributes of the display monitor.
|
|
///
|
|
/// This member can be the following value:
|
|
/// 1 : MONITORINFOF_PRIMARY
|
|
/// </summary>
|
|
public uint Flags;
|
|
|
|
/// <summary>
|
|
/// A string that specifies the device name of the monitor being used. Most applications have no use for a display monitor name,
|
|
/// and so can save some bytes by using a MONITORINFO structure.
|
|
/// </summary>
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHDEVICENAME)]
|
|
public string DeviceName;
|
|
|
|
public void Init()
|
|
{
|
|
Size = 40 + 2 * CCHDEVICENAME;
|
|
DeviceName = string.Empty;
|
|
}
|
|
}
|
|
}
|