.net - 扩展的打开/保存文件对话框中的视觉样式异常

标签 .net windows user-interface savefiledialog

我关注了this article这解释了如何使用 .NET 扩展 Windows 的内置文件打开/保存对话框。经过一些小改动后,一切正常,但对话框的外观与其他对话框略有不同。这并不重要,但我很好奇背后的原因是什么。

我的对话框(平面按钮): My Dialog (flat buttons)

其他对话框(3D 按钮):Other dialogs (3D style buttons)

最佳答案

来自那篇文章的评论:

The SaveFileDialogWithEncoding example is great. However, the look and feel are "old style" -- in other words, the buttons and controls don't have the new "XP look" (i.e. rounded buttons, etc.). It's probably a flag setting in one of the fields in the OPENFILENAME structure and I'm looking into that. I was just wondering if you (or anyone else) had any insight to solving that problem.

然后是 self 回答:

Never mind -- figured it out. Before you instantiate the form object you need to call Application.EnableVisualStyles() like so:

[STAThread]
static void Main() 
{
  Application.EnableVisualStyles();
  Application.Run(new Form1());
}

关于.net - 扩展的打开/保存文件对话框中的视觉样式异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11307258/

相关文章:

c# - .NET 垃圾收集器能否收集作为类成员的对象?

windows - 获取应用程序池的标识

c - 如何使用 .exe 文件传送 .dll 文件

java - 如何测试我的 jradiomenubutton 是否是我想要的值

java - Swing 石头剪刀布核弹 super 错误

.net - 异步等待 n 件事发生

.net - Visual Studio 在构建时挂起

c# - 阅读 .Net 堆栈跟踪

Windows 10 和 Netbeans : no write permissions

javascript - 为什么使用 'href="javascript :void(0) ;"' instead of something more user friendly?