.net 如何让窗体看起来更漂亮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5013485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make window forms look More Beautiful
提问by user580927
I have a Windows Forms application written in C#. I have to make my form's design more attractive (Windows 7 look). Are there are any third party tools to make forms look more beautiful?
我有一个用 C# 编写的 Windows 窗体应用程序。我必须使我的表单设计更具吸引力(Windows 7 外观)。有没有第三方工具可以让表格看起来更漂亮?
回答by Cody Gray
If you're trying to theme the built-in controls with the Windows Aero user interface, you can find several drop-in control libraries online.
如果您尝试使用 Windows Aero 用户界面为内置控件设置主题,您可以在线找到几个插入式控件库。
- Windows Forms Aero
- Aero.Controls
- Microsoft's Windows API Code Pack for the .NET Framework
- Fully themed Windows Vista Controls
Most of those libraries include support for the Desktop Window Manager functions, including adding the Aero Glass effect to your application. Daniel Moth explains this in greater detail in a series of articles on his blog:
这些库中的大多数都支持桌面窗口管理器功能,包括将 Aero Glass 效果添加到您的应用程序中。Daniel Moth 在其博客上的一系列文章中更详细地解释了这一点:
- Vista: Glass in C#
- Glass in C#, an alternative approach
- Vista glass answers and DwmEnableBlurBehindWindow
Of course, you can quickly get in over your head. In particular, the standard controls do not render correctly over glass because the color black is rendered as transparent. Anything that displays black
text will look washed out and be unreadable. The right way to draw text and images on the extended glass area is described here: Drawing smooth text and pictures on the extended glass area.
当然,你可以很快进入你的头脑。特别是,标准控件无法在玻璃上正确呈现,因为黑色呈现为透明。任何显示黑色
文本的东西都会看起来褪色并且无法阅读。在扩展玻璃区域上绘制文本和图像的正确方法在这里描述:在扩展玻璃区域上绘制平滑的文本和图片。
You'll also have to remember that these features are onlyavailable on Windows Vista and later versions. If your application needs to run under Windows XP (which it probably does), you're going to have to make sure that your application falls back gracefully and that you UI looks good there, too.
您还必须记住,这些功能仅适用于 Windows Vista 和更高版本。如果您的应用程序需要在 Windows XP 下运行(它可能会这样做),您将必须确保您的应用程序优雅地回退并且您的 UI 在那里看起来也很好。
If you need more information on Aero Glass effects, search Stack Overflow. Myself and many others have posted lots of answers to related questions. For example, this one, and this one, and this one.
如果您需要有关 Aero Glass 效果的更多信息,请搜索 Stack Overflow。我自己和许多其他人已经发布了很多相关问题的答案。例如,这个一个,这个一个,这个一个。
In general, however, my suggestion is to use the glass effect sparingly and only when you really feel that it adds something to your application. Don't just throw in gratuitous eye candy because you can. The most important thing is to focus on the usabilityof your application, from the perspective of its typical user. There is no reason to add additional complexity that doesn't provide any real usability benefits.
然而,总的来说,我的建议是谨慎使用玻璃效果,并且仅当您真的觉得它为您的应用程序增加了一些东西时。不要因为你可以就扔掉免费的眼睛糖果。最重要的是从典型用户的角度关注应用程序的可用性。没有理由增加不提供任何真正可用性优势的额外复杂性。
回答by Ben Gates
Try using Application.EnableVisualStyles(). Make sure to call it before Application.Run().
尝试使用Application.EnableVisualStyles(). 确保在 之前调用它Application.Run()。
Application.EnableVisualStyles();
Application.Run(new Form());
回答by Yogesh
For Vista Aero glass effect, see this for a starting point: Windows Vista Aero Pt. 1 - Adding Glass to a Windows Forms Application
对于 Vista Aero 玻璃效果,请参阅此起点: Windows Vista Aero Pt。1 - 将 Glass 添加到 Windows 窗体应用程序

