Unc*_*aul 5 .net windows wpf titlebar
到目前为止,我尝试通过 SendMessage 和其他几个调用使用 GetThemePartSize、GetThemeMetric、GetSystemMetrics、WM_GETTITLEBARINFOEX,但没有任何东西接近真实尺寸(启用了主题的 Windows 7)。
基本上我的问题是:如何获得这些按钮的大小(和位置,理想情况下甚至是手柄)以及从 GetThemePartSize 检索到的值甚至意味着什么?它们有什么用?
谢谢
更新
对于汉斯:
[DllImport("uxtheme", ExactSpelling=true)]
private extern static Int32 GetThemePartSize(IntPtr hTheme, IntPtr hdc, WindowPart part, WindowPartState state, ref RECT pRect, ThemeSize eSize, out SIZE size);
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential)]
private struct SIZE
{
public int cx;
public int cy;
}
private const int TS_TRUE = 1;
private const int CBS_NORMAL = 1;
private const int WP_CLOSEBUTTON = 18;
private const string VSCLASS_WINDOW = "WINDOW";
/* inside a method */
var rect = new RECT {left = 0, right = 200, top = 0, bottom = 200};
var size = new SIZE();
var windowHandle = new WindowInteropHelper({MyWindow}).Handle;
var theme = OpenThemeData(windowHandle, VSCLASS_WINDOW);
GetThemePartSize(theme, null, WP_CLOSEBUTTON, CBS_NORMAL, ref rect, TS_TRUE, ref size);
// result on w7 with default theme -> size.cx == 28, size.cy == 17
Run Code Online (Sandbox Code Playgroud)
您可以将 Microsoft.Windows.Shell.dll 与自定义 chrome 窗口库结合使用来修改或处理窗口按钮。我使用它来创建 Windows 8 ui 风格的应用程序
http://www.codeproject.com/Articles/131515/WPF-Custom-Chrome-Library
http://archive.msdn.microsoft.com/WPFShell
| 归档时间: |
|
| 查看次数: |
1590 次 |
| 最近记录: |