GetSystemMetrics() returns different results for .NET 4.5 & .NET 4.0

房东的猫 提交于 2019-11-28 12:18:31

So, it's actually a by-design behavior, and if someone has similar issues, here is the code which always outputs the same result:

const int CXFRAME = 0x20;
const int CYFRAME = 0x21;
const int CXPADDEDBORDER = 92;

var dx = GetSystemMetrics(CXFRAME);
var dy = GetSystemMetrics(CYFRAME);
var d  = GetSystemMetrics(CXPADDEDBORDER);
dx += d;
dy += d;

Console.WriteLine("{0}x{1}", dx, dy);
Console.ReadKey();

Also note that RibbonWindow WPF control, which uses WindowChrome and now comes as a part of .NET 4.5 does not know about this changes and displays messy window borders (fortunately, I think it can be fixed using modified styles).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!