-
-
-
using System.Runtime.InteropServices;
-
-
-
-
public class PrimaryScreen
-
-
-
[DllImport("user32.dll")]
-
static extern IntPtr GetDC(IntPtr ptr);
-
-
static extern int GetDeviceCaps(
-
IntPtr hdc, // handle to DC
-
int nIndex // index of capability
-
-
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
-
static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
-
-
-
-
-
const int LOGPIXELSX = 88;
-
const int LOGPIXELSY = 90;
-
const int DESKTOPVERTRES = 117;
-
const int DESKTOPHORZRES = 118;
-
-
-
-
-
-
-
public static Size WorkingArea
-
-
-
IntPtr hdc = GetDC(IntPtr.Zero);
-
-
size.Width = GetDeviceCaps(hdc, HORZRES);
-
size.Height = GetDeviceCaps(hdc, VERTRES);
-
ReleaseDC(IntPtr.Zero, hdc);
-
-
-
-
-
-
-
-
-
-
-
IntPtr hdc = GetDC(IntPtr.Zero);
-
int DpiX = GetDeviceCaps(hdc, LOGPIXELSX );
-
ReleaseDC(IntPtr.Zero, hdc);
-
-
-
-
-
-
-
-
-
-
-
IntPtr hdc = GetDC(IntPtr.Zero);
-
int DpiX = GetDeviceCaps(hdc,LOGPIXELSY);
-
ReleaseDC(IntPtr.Zero, hdc);
-
-
-
-
-
-
-
public static Size DESKTOP
-
-
-
-
IntPtr hdc = GetDC(IntPtr.Zero);
-
-
size.Width = GetDeviceCaps(hdc,DESKTOPHORZRES );
-
size.Height = GetDeviceCaps(hdc, DESKTOPVERTRES);
-
ReleaseDC(IntPtr.Zero, hdc);
-
-
-
-
-
-
-
-
public static float ScaleX
-
-
-
-
IntPtr hdc = GetDC(IntPtr.Zero);
-
int t = GetDeviceCaps(hdc, DESKTOPHORZRES);
-
int d = GetDeviceCaps(hdc, HORZRES);
-
float ScaleX = (float)GetDeviceCaps(hdc, DESKTOPHORZRES) / (float)GetDeviceCaps(hdc, HORZRES);
-
ReleaseDC(IntPtr.Zero, hdc);
-
-
-
-
-
-
-
public static float ScaleY
-
-
-
-
IntPtr hdc = GetDC(IntPtr.Zero);
-
float ScaleY = (float)(float)GetDeviceCaps(hdc, DESKTOPVERTRES) / (float)GetDeviceCaps(hdc, VERTRES);
-
ReleaseDC(IntPtr.Zero, hdc);
-
-
-
-
-
-