为 XP 和 Vista/Windows 7 创建 Win32 应用程序
我使用纯 win32 api(无 MFC 或 WPF)用 C++ 编写了一个应用程序。 我希望相同的 .exe 在 Windows XP 和 Windows Vista / Windows 7 下运行。
我使用清单将视觉样式添加到应用程序中的控件。但是,当我在 XP 计算机上测试该应用程序时,按钮不显示。只有编辑控件和菜单栏可以。
编辑:我想我忘了提及这一点,但该应用程序在 WIndows 7/Vista 上运行良好。 编辑2:我正在使用 MinGW 编译器 我认为这是清单的问题,所以我删除了它并重新编译了我的程序。但按钮仍然不显示。 我正在使用的清单如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="BlackJack.Viraj"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.2600.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
问题出在清单中还是其他原因?
I've written an application in C++ using the pure win32 api (no MFC or WPF).
I want the same .exe to run under both Window's XP and Windows Vista / Windows 7.
I was using a manifest to add Visual Styles to the controls in my application. However, when I tested the app on an XP Machine, Buttons do not show up. Only Edit controls and the Menu Bar do.
Edit: I think I forgot to mention this, but the application works fine on WIndows 7/Vista.
Edit 2: I'm using the MinGW compiler
I thought that this was a problem with the manifest, so I removed it and recompiled my program. But the buttons still don't show up.
The manifest that I am using is as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="BlackJack.Viraj"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.2600.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Does the problem lie in the manifest or is it something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
确保调用 InitCommonControlsEx
Make sure you call InitCommonControlsEx
这是另一回事。假设它们是正常的标准按钮,无论清单是什么样子,或者是否有,它们都应该显示。还有其他事情正在发生。
It's something else. Assuming they are the normal, standard buttons they should show up no matter what the manifest looks like, or whether or not there is one. Something else is going on.
除非您使用新的 Windows 7 API,否则标准应用程序将适用于这两个平台。此外,Windows 7 还具有兼容模式,如果您发现有问题,可以尝试一下。
您确定在程序开始时调用了 InitCommonControls API 吗?
了解它为何如此重要 - http://blogs.msdn。 com/b/oldnewthing/archive/2005/07/18/439939.aspx
我建议您参考纯Win32应用程序
http://blogs.msdn.com/b/oldnewthing /archive/2005/04/22/410773.aspx
另外,我建议将清单放在源文件中的链接器选项本身中。
Unless you're using new Windows 7 API, a standard application will go well with both platform. Also Windows 7 has compatibility mode to try out if you find something broken.
Are you sure that you've called InitCommonControls API in the beginning of your program?
See why it's important - http://blogs.msdn.com/b/oldnewthing/archive/2005/07/18/439939.aspx
I'd suggest you to refer a pure Win32 Application
http://blogs.msdn.com/b/oldnewthing/archive/2005/04/22/410773.aspx
Also I'd suggest putting the manifest within the Linker options itself in the source file.
清单很好。因此问题一定出在你的代码中。创建主题应用程序与非主题应用程序并不完全相同。
The manifest is fine. Therefore the problem must be in your code. Creating a themed application isn't quite the same as a non-themed one.