开启程序的Visual Styles

首先看看MS对Visual Styles的解释:

Windows XP and later operating systems support a feature called visual styles that enables the appearance of common controls to change based on the theme chosen by the user. Prior to Windows 8, you must specifically configure your application to use visual styles; otherwise, the application‘s common controls are always rendered in the style associated with the Windows Classic theme, regardless of the currently selected theme. In Windows 8, visual styles can‘t be turned off, Windows Classic mode no longer exists, and high contrast mode has been modified to work with visual styles.

XP以后的系统支持一种叫做可视化风格的界面,界面可以随着系统的主题改变而变化。程序必须明确的去启用这种风格,否则程序就是经典风格界面 ,程序界面不随系统主题而改变。win8还新增了一种高对比度模式的界面,暂不讨论。

http://msdn.microsoft.com/en-us/library/windows/desktop/bb773187(v=vs.85).aspx

可以明显感觉visual styles要圆润漂亮了很多

开启 Visual Styles的方法

要使用 Visual Styles,需要第六版或更新的的ComCtl32.dll, ComCtl32.dll不重发行,只是预置在系统当中。xp以后的系列都同时有第五版和第六版的

ComCtl32.dll,第六版的ComCtl32.dll包含user controls and the common controls。默认情况下程序使用定义在User32.dll中的user controls  和定义在第五版 ComCtl32.dll 中的 common controls

comCtl32.dll版本介绍

ComCtl32.dll
Version Distribution Platform
4.0 Windows 95 and Microsoft Windows NT 4.0
4.70 Internet Explorer 3.0
4.71 Microsoft Internet Explorer 4.0
4.72 Microsoft Internet Explorer 4.01 and Windows 98
5.80 Windows 98 Second Edition and Microsoft Internet Explorer 5
5.81 Windows Millennium Edition (Windows Me), Windows 2000, Microsoft Internet Explorer 5.01, Microsoft Internet Explorer 5.5, and Microsoft Internet Explorer 6
5.82 Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, and Windows 7
6.0 Windows XP, Windows Server 2003
6.10 Windows Vista, Windows Server 2008, and Windows 7

http://msdn.microsoft.com/en-us/library/windows/desktop/hh298349(v=vs.85).aspx

@:添加程序清单的方法1

在工程目录下新建一个文本xml格式的清单文件“程序名.exe.manifest”,然后添加到资源中,文件内容为

[html] view plain copy

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  3. <assemblyIdentity
  4. version="1.0.0.0"
  5. processorArchitecture="*"
  6. name="CompanyName.ProductName.YourApplication"
  7. type="win32"
  8. />
  9. <description>Your application description here.</description>
  10. <dependency>
  11. <dependentAssembly>
  12. <assemblyIdentity
  13. type="win32"
  14. name="Microsoft.Windows.Common-Controls"
  15. version="6.0.0.0"
  16. processorArchitecture="*"
  17. publicKeyToken="6595b64144ccf1df"
  18. language="*"
  19. />
  20. </dependentAssembly>
  21. </dependency>
  22. </assembly>

mainfest详解:

description段 assemblyIdentity 元素的属性集

Attribute Description
version Version of the manifest. The version must be in the form major.minor.revision.build (that is, n.n.n.n, where n <=65535).
processorArchitecture Processor for which your application is developed.
name Includes company name, product name and application name.
type Type of your application, such as Win32.

dependency段 assemblyIdentity 元素的属性集

Attribute Description
type Type of the dependency component, such as Win32.
name Name of the component.
version Version of the component.
processorArchitecture Processor that the component is designed for.指定处理器。有效值为 msil、x86、IA64 和 amd64。
publicKeyToken Key token used with this component.
language Language of the component.

@:添加程序清单的方法2

在vs2005以后,设置visual styles可以不需要程序部署清单文件,而只是发送一个编译指令。在“stdafx.h”中添加一下几行就可以了

[cpp] view plain copy

  1. #pragma comment(linker,"\"/manifestdependency:type=‘win32‘ \
  2. name=‘Microsoft.Windows.Common-Controls‘ version=‘6.0.0.0‘ \
  3. processorArchitecture=‘*‘ publicKeyToken=‘6595b64144ccf1df‘ language=‘*‘\"")

MSND上说还需

[cpp] view plain copy

  1. <span style="white-space:pre">  </span>// 如果一个运行在 Windows XP 上的应用程序清单指定要
  2. // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
  3. //则需要 InitCommonControlsEx()。否则,将无法创建窗口。
  4. INITCOMMONCONTROLSEX InitCtrls;
  5. InitCtrls.dwSize = sizeof(InitCtrls);
  6. // 将它设置为包括所有要在应用程序中使用的
  7. // 公共控件类。
  8. InitCtrls.dwICC = ICC_WIN95_CLASSES;
  9. InitCommonControlsEx(&InitCtrls);

但是发现不添加也没事,xp也可正常实现,懂得可以给说说

@:关闭Visual Styles

1:可以调用SetWindowTheme函数关闭一个或多个控件的visual styles

[cpp] view plain copy

  1. #include "Uxtheme.h"
  2. #pragma comment(lib,"UxTheme.lib")

[cpp] view plain copy

  1. SetWindowTheme(hwnd, L" ", L" ");

2:也可以调用InitInstance之前调用void SetThemeAppProperties( DWORD dwFlags),不设置 STAP_ALLOW_NONCLIENT 标志可关闭整个程序所有窗口的的Visual Styles

[cpp] view plain copy

  1. #include "Uxtheme.h"
  2. #pragma comment(lib,"UxTheme.lib")

[cpp] view plain copy

  1. DWORD dwFlags = (STAP_ALLOW_CONTROLS | STAP_ALLOW_WEBCONTENT);
  2. SetThemeAppProperties(dwFlags);

http://blog.csdn.net/x356982611/article/details/18403869

时间: 2024-08-27 15:44:19

开启程序的Visual Styles的相关文章

使用 ODBC .NET 提供程序和 Visual C# .NET 执行 SQL 参数化存储过程

http://support2.microsoft.com/kb/310130/zh-cn 此分步指导文章描述如何使用 ODBC .NET 托管提供程序和 Visual C# .Net 调用参数化 SQL Server 存储过程. 尽管使用 ODBC .NET 提供程序执行参数化存储过程与使用 SQL 或 OLE DB 提供程序执行同一存储过程差别不大,但一个重要的差别是:存储过程必须使用 ODBC CALL 语法进行调用,而不能使用存储过程的名称.有关此 CALL 语法的其他信息,请参见 MS

怎么用visual studio2010编写c++程序|用visual studio2010编写c++程序的步骤

如何通过visual studio 2010编写一个简单的c++程序,随小编不一起看看如何编写. 首先打开visual studio 2010 点击软件左上角“文件-新建-项目”,选择“win32-win32控制台应用程序”,输入一个名称如简单程序,点击确定 点击“下一步”,勾选“空项目”,点击完成 右击源文件,“添加-新建项” 选择c++文件,输入名称如简单程序,单击添加 我们以hello world为例,编写如下代码,写好代码,点击“调试-开始执行(不调试)”,发现运行成功.

开启程序子进程的方式

开启进程的方式 串行:一个完完整整的执行完再执行下一个 并发:看起来是同时运行的 并行:真正做到了同时运行多道技术(了解) 空间复用:共用一个内存条,每一个进程都有自己独立的内存空间,互不干扰,物理级别的隔离 空间复用:共用一个cpu cpu切换(掌握) io的时候,占用时间过长 切换现代计算机:现在的主机一般是多核,那么每个核都会利用多道技术 有4个cpu,运行于cpu1的某个程序遇到io阻塞,会等到io结束再重新调度,会被调度到 4个cpu的任意一个,具体由操作系统调度算法决定 并发:切换+

职场软技能:开启程序员的“破冰之旅”

在我们聊"软技能"之前,先来区分下"软技能"和"硬实力".通常我们将自己专业方向的技能定义为 "硬技能",以程序员为例的话,我们的算法.计算机知识和编程能力等就属于"硬技能",是我们吃饭的家伙,大多数人等着靠他赚钱买车买房娶妻生子,但生活质量的好坏往往由"软技能"决定的,从两类技能的关系来看,"软技能"是"硬技能"的催化剂. 常说的"软技

使用Visual Studio Code创建第一个ASP.NET Core应用程序

全文翻译自:Your First ASP.NET Core Application on a Mac Using Visual Studio Code 这篇文章将向你展示如何在Mac上写出你的第一个ASP.NET Core应用程序. 本文内容: 搭建开发环境 使用Yeoman搭建应用程序 使用Visual Studio Core开发ASP.NET应用程序 使用Kestrel在本地运行这个应用程序 将这个应用程序发布至Azure 学习资源 搭建开发环境 在你的开发机上下载并安装.Net Core和

在 Oracle 数据库上使用 Visual Studio 2005 或 2008 构建 .NET 应用程序 了解构建使用 Oracle 数据库的 .NET 应用程序所涉及到的基本但不可或缺的过程。

随着 Microsoft 的 .NET Framework 的日益流行,许多开发人员迫切想了解关于将 .NET 应用程序与 Oracle 集成的最佳方法的信息 - 不仅在基本连通性方面,还包括与使用 Visual Studio 2005 或 2008 进行有效应用程序开发的关系. 在本文中,我将说明构建使用 Oracle 数据库的 .NET 应用程序所涉及到的基本但不可或缺的过程,包括: 如何添加工程引用,以在您的 .NET 工程中支持 Oracle 类 如何创建 Oracle 数据库连接字符串

Visual Studio 2017 发布

https://www.visualstudio.com/zh-cn/news/releasenotes/vs2017-relnotes 发布日期:2017 年 3 月 7 日 摘要 开发:快速导航.编写并修复代码 新的安装体验 - 降低了最小内存需求量以实现更快.更定制化的安装,并且支持脱机安装. Visual Studio IDE - 大幅改进了 Visual Studio 2017,包括减少启动和解决方案加载时间.改进登录和标识.改进代码导航以及增添打开文件视图和链接的服务,实现了应用和任

Visual Studio跨平台开发(1):Hello Xamarin!

前言 应用程序发展的脚步, 从来没有停过. 从早期的Windows 应用程序, 到网络时代的web 应用程序, 再到近几年相当盛行的行动装置应用程序(Mobile Application), 身为C#的开发人员与Visual Studio的使用者. Windows Phone与Windows Store App的开发是否已满足不了你了呢? 如果能夠让你使用C#及Visual Studio 来开发iOS及Android的app. 是否能再度唤醒你的开发魂? Xamain 正是为了这样的需求而诞生的

[Tool] 使用CodeMaid自动程序排版

[Tool] 使用CodeMaid自动程序排版 前言 「使用StyleCop验证命名规则」这篇文章,指引开发人员透过StyleCop这个工具,来自动检验项目中产出的程序代码是否合乎命名规则. [Tool] 使用StyleCop验证命名规则 但是在项目开发的过程中,如果只是验证命名规则.而没有统一程序排版,项目中很容易就会出现类似下列范例的程序代码产出.这样的产出,虽然能够正常地提供项目功能.并且符合微软的命名规则,但是因为程序排版凌乱的问题,大幅降低了这份程序代码的可维护性. Bad Code