怎么让自定义的Cursor,在DPI变化时跟着变。
有一个WPF的程序,上面有一个自定义的cursor,希望在DPI变化时,那个cursor跟着变大或变小。有什么好办法吗?谢谢。
能想到的办法是做三个不同大小的cursor,然后,在不同dpi下,用不定cursor. --------------------编程问答-------------------- 帮你顶下 接分 --------------------编程问答-------------------- 从别处找了一段得dpi的。WPF有自带的能解决问题的方法吗?
--------------------编程问答--------------------
private const int HORZRES = 8;
private const int VERTRES = 10;
private const int LOGPIXELSX = 88;
private const int LOGPIXELSY = 90;
[DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
private static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("Gdi32.dll", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
private static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
private const int kBaseDpi = 96;
private const int kLargeDpi = 144;
private const int kLargest = 192;
static int getDpi()
{
IntPtr dc = GetDC(IntPtr.Zero);
return GetDeviceCaps(dc, LOGPIXELSX);
}
Matrix m =
PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
double dx = m.M11;
double dy = m.M22;
From:
http://blogs.msdn.com/b/jaimer/archive/2007/03/07/getting-system-dpi-in-wpf-app.aspx
补充:.NET技术 , C#