有一个WPF的程序,上面有一个自定义的cursor,希望在DPI变化时,那个cursor跟着变大或变小。有什么好办法吗?
谢谢。能想到的办法是做三个不同大小的cursor,然后,在不同dpi下,用不定cursor.
谢谢。能想到的办法是做三个不同大小的cursor,然后,在不同dpi下,用不定cursor.
解决方案 »
- 在练习接口的时候提示,并非所有代码路径都有返回值?
- c# 财付通 收款方或发布方尚未设置KEY 在线等
- 关于Repeater与RadioButton 实现投票的功能。(救急)
- VS2005创建的C++项目使用的是非托管的代码的吗
- DataGrid怎样动态修改超级连接列?
- 用程序实现像ie的查看网页源文件,为什么显示的源文件的汉字是乱码?
- 请教:在开发前和开发过程中有什么好办法能让BUG尽量少的出现呢?
- 做一个C/S结构的系统,客户端和服务器端一般采用何种连接方式?Remoting?TCP?
- 100分求c# 写出账务软件中的凭证录入界面!或给点思路!
- 如何解压rar文件,不用调用winrar.exe解压,而是用代码.
- 求助!asp.net web应用程序中日期格式问题
- WinForm如何动态加载用户控件,在线等。
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