当前位置:编程学习 > C#/ASP.NET >>

怎么让自定义的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#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,