基于Windows版本更改控件的视觉样式 [英] Changing visual style of controls based on windows version

查看:424
本文介绍了基于Windows版本更改控件的视觉样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让vista / win7使用Aero风格的窗口,而XP用户使用正常的窗口风格(如何获得Windows XP stlye而不是win95样式btw?)

I'm looking to have vista/win7 use Aero-style windows while XP users use normal window style (how does one get windows XP stlye and not win95 styles btw?)

这个想法是这样的:

OSVERSIONINFOEX osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx((OSVERSIONINFO*)&osvi);
if (osvi.dwMajorVersion > 5) {
               #pragma comment(linker,"/manifestdependency:\"type='win32' "\
               "name='Microsoft.Windows.Common-Controls' "\
               "version='6.0.0.0' "\
               "processorArchitecture='x86' "\
               "publicKeyToken='6595b64144ccf1df' "\
               "language='*' "\
               "\"")
}


b $ b

现在,#pragma被执行,无论if语句是真还是假,我猜是#pragma的工​​作方式。当然有一些其他的方法来使这个工作(像#ifndef #define ... #endif我猜)

Now, the #pragma gets executed no matter if the if-statement is true or false, which I guess is just the way #pragma works. Surely there is some other way to get this to working (something like #ifndef #define ... #endif I guess)

干杯

推荐答案

您正在将编译时的编译时评估与代码的运行时执行混合在一起。显然这将不起作用。

You are mixing compile-time evaluation of pragma with run-time execution of code. Obviously this won't work.

可以在PutYourProgramNameHere.exe.manifest文件中保存应用程序的清单。因此,如果您需要不同的清单XP和Vista / Win7,那么您可以在目标计算机上安装应用程序时安装不同的清单文件。也就是说您的安装程序会检查操作系统版本并安装匹配的清单。

It's possible to keep a manifest for the application in "PutYourProgramNameHere.exe.manifest" file. So if you need different manifests for XP and Vista/Win7, then you can install different manifest files when you install the application on the target computer. I.e. your installer checks OS version and installs matching manifest.

这篇关于基于Windows版本更改控件的视觉样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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