镀铬样式C#应用程序? [英] Chrome Style C# Applications?

查看:142
本文介绍了镀铬样式C#应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在谈论Vista的玻璃功能,我已经知道如何来实现这一目标。我正在谈论的特点是控件添加到工具栏,如办公2007年确实与标志和工具栏。

I'm not talking about the vista glass feature, I already know how to accomplish that. The feature that I'm talking about is add controls to the titlebar, like office 2007 does with the logo and toolbar.

推荐答案

你需要做一些Win32的互操作,以达到这样的效果。根据您是否正在使用的WinForms或WPF,你勾消息处理不同的方式(我不记得的WinForms,所以我给所有的例子为WPF)。但是,在这两种情况下,你需要:

You need to do some Win32 interop to achieve that effect. Depending on whether you are using Winforms or WPF, the way you hook to the message processing differs (I don't remember Winforms, so I'll give all examples for WPF). But in both cases, you need to:


  1. 拦截创建窗口并修改窗口样式和扩展样式。在WPF中,你需要从 HwndSource 和修改 HwndSourceParameters 的,以实现这一点。你需要定期的风格和WS_EX_WINDOWEDGE和WS_EX_APPWINDOW扩展样式WS_OVERLAPPEDWINDOW,WS_CLIPSIBLINGS和WS_VISIBLE。

  1. Intercept the creation of the window and modify the window styles and extended styles. In WPF you need to inherit from HwndSource and modify the HwndSourceParameters in order to achieve this. You need WS_OVERLAPPEDWINDOW, WS_CLIPSIBLINGS and WS_VISIBLE for regular style and WS_EX_WINDOWEDGE and WS_EX_APPWINDOW extended styles.

添加一个消息处理程序throught他HwndSource参数HwndSourceHook。

Add a message handler throught he HwndSource parameters HwndSourceHook.

在消息PROC通过挂钩加入步骤二,你需要处理几个消息:

In the message proc added through the hook in step two, you need to process several messages:


  • WM_NCACTIVATE - 当应用程序被激活或不更改标题的油画

  • WM_NCCALCSIZE - 回到那个你不必非客户端领域
  • $ b操作系统$ b
  • WM_NCPAINT - 一般你只需要在这里invaldate窗口RECT时,WPF会照顾实际绘画)

  • WM_NCHITTEST - 处理窗口移动,最小化和最大化。

  • WM_NCACTIVATE - to change the painting of the title when the app is activated or not
  • WM_NCCALCSIZE - to return to the OS that you don't have non-client areas
  • WM_NCPAINT - in general you need to invaldate the window rect only here, the WPF will take care of the actual painting)
  • WM_NCHITTEST - to process the moving of the window, minimizing and maximizing.

一旦你做到哪里WPF是要画你的视觉树是要跨越整个上面,你的客户区窗口的面积。您将需要添加的非cliet的视觉效果,使您的应用程序看起来像一个普通的应用程序给用户

Once you do the above, your client area where WPF is going to paint your visual tree is going to span the whole area of the window. You will need to add the "non-cliet" visuals so that your application looks like a regular application to the user.

您可能需要几个信息:

You might need several more messages:


  • WM_THEMECHANGED 如果你想改变你的非客户区域画是与OS主题

  • WM_DWMCOMPOSITIONCHANGED ,如果​​你想扩展玻璃并获得标准的操作系统NC-玻璃画,当玻璃被启用并切换到您的定制逻辑,当玻璃是没有的。

  • WM_THEMECHANGED if you want to change your "non-client" area painting to be consistent with the OS theme
  • WM_DWMCOMPOSITIONCHANGED if you want to extend glass and get the standard OS NC-glass painting when glass is enabled and switch to your custom logic when glass is not.

如果你想要去得到边界,标题,关闭,mininmize标准Win32资产和最大化按钮在非客户区域使用你可能想看看在Win32主题的API。

You might want to look at the Win32 Theme APIs if you want go get the standard Win32 assets for borders, caption, close, mininmize and maximize buttons to use in your 'non-client" area.

如果你想玻璃延伸到你的窗口,你可以看看:

If you want to extend Glass into your window, you can look at:

  • DwmExtendFrameIntoClientArea - to get the standard glass NC-area
  • DwmDefWindowProc - to get the desktop manager to paint Glass and the standard NC controls
  • DwmIsCompositionEnabled - to determine if Glass is enabled; you can use the above two APIs only when Glass is enabled. If Glass is not enabled, you need to do your own drawing of the NC area.

您可以找到您需要 p的所有邮件,风格恰当的C#的定义和相应的Win32 API /调用

您还可以通过使用标准的WPF窗口中出现了 WindowStyle =无达到类似的效果。但是,会有对你的应用程序和其他应用程序在桌面上的行为之间存在一些差异;最明显的他们是,你将无法通过任务栏上右键单击堆叠或平铺窗口。

You could also achieve similar effect by using standard WPF window with a WindowStyle=none. However, there will be some differences between the behavior of the desktop towards your app and other apps; most obvious of them is that you won't be able to stack or tile your window by right-clicking on the taskbar.

您还可以看看一些第三方组件,使一些这种功能。我没有用过(正如你所看到的,我并不害怕的Win32互操作:-)的),所以我不建议你任何特定的。

You can also look into some third-party components that enable some of this functionality. I have not used any (as you can see, I am not scared of Win32 interop :-)), so I can't recommend you any particular.

这篇关于镀铬样式C#应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆