为.NET程序中的系统对话框启用XP外观

.NET程序中的有些对话框实际上是对Win32对话框的封装,比如MessageBox.在默认情况下,新建立的.NET程序中使用MessageBox.Show()打开MessageBox时,此对话框的样式为Windows2000风格:

ScreenShot00084

若要启用XP/Visat/Win7系统的新风格,可以为程序添加一个manifest配置文件:

1.在.net项目中添加一个app.manifest配置文件:

ScreenShot00085

2.打开所添加的app.manifest文件,找到系统控件风格配置代码:

  1: <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
  2:    <!--<dependency>
  3:     <dependentAssembly>
  4:       <assemblyIdentity
  5:           type="win32"
  6:           name="Microsoft.Windows.Common-Controls"
  7:           version="6.0.0.0"
  8:           processorArchitecture="*"
  9:           publicKeyToken="6595b64144ccf1df"
 10:           language="*"
 11:         />
 12:     </dependentAssembly>
 13:   </dependency>-->

3.去掉dependentAssembly节点的注释标记,然后重新编译程序,即可启用新的系统控件外观风格:

ScreenShot00086

posted on 2010-06-02 13:01  wudong  阅读(479)  评论(0编辑  收藏  举报

导航