添加项目文件。

This commit is contained in:
Administrator
2026-08-04 18:36:40 +08:00
parent 16fb9e4f5a
commit a2ecbc795d
616 changed files with 149853 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace JinYuan.ControlLib.UCHelper
{
/// <summary>
/// 系统缩放比例
/// </summary>
public class DpiHelper
{
#region 公开方法
/// <summary>
/// 获取控件对应的系统缩放比例
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
public static float GetControlDpi(Control control)
{
IntPtr hDC = IntPtr.Zero;
Graphics g = null;
ControlHelper.GetWindowClientGraphics(control.Handle, out g, out hDC);
float dpi = g.DpiX / 96f;
g.Dispose();
NativeMethods.ReleaseDC(control.Handle, hDC);
return dpi;
}
/// <summary>
/// 获取控件对应的系统缩放比例
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
public static float GetControlDpi(IntPtr hWnd)
{
IntPtr hDC = IntPtr.Zero;
Graphics g = null;
ControlHelper.GetWindowClientGraphics(hWnd, out g, out hDC);
float dpi = g.DpiX / 96f;
g.Dispose();
NativeMethods.ReleaseDC(hWnd, hDC);
return dpi;
}
#endregion
}
}