禁用清单中的视觉样式,同时保留通用控件功能

发布于 2025-01-03 22:12:49 字数 636 浏览 4 评论 0原文

我使用的是纯 WINAPI,需要发送 TB_GETMETRICS 消息。但是,只有当您将清单文件添加到应用程序并引用 Common Controls 版本 6.0 时,该消息才会起作用。我添加了它,该消息有效,但现在我的应用程序正在使用 Vista/Windows 7 视觉样式,这是我不想要的。

有没有办法在使用经典主题时保留 Common Controls 6.0 引用,无论是通过修改清单文件还是通过调用某些 API 函数?

注意:我尝试了 SetWindowTheme 但结果是 Classic 和 Aero 的混合。

编辑:我没有正确阅读 SetWindowTheme 函数,所以我想为父级 hWnd 调用它会自动为它的所有子级调用它。事实证明,我需要为每个想要使用 Windows Classic 的控件调用它。现在它正在正常工作。

I'm using pure WINAPI, and need to send the TB_GETMETRICS message. However, that message only works if you add a manifest file to your application with a reference to Common Controls version 6.0. I added it, the message is working, but now my application is using Vista/Windows 7 visual styles, which I do not want.

Is there any way to keep the Common Controls 6.0 reference while using Classic theme, either by modifying the manifest file or by calling some API function?

Note: I tried SetWindowTheme but the result was a mix of Classic and Aero.

EDIT: I hadn't read the SetWindowTheme function correctly, so I was thinking calling it for the parent hWnd would automatically call it for all its child. It turns out I need to call it for each control I want to use Windows Classic. It's working as it should now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

つ低調成傷 2025-01-10 22:12:49

要禁用所有控件的视觉样式,请在创建主窗口之前调用 SetThemeAppProperties(STAP_ALLOW_NONCLIENT)SetThemeAppProperties(0)

要禁用每个 HWND 的视觉样式,您可以调用 SetWindowTheme(hwndControl,L"",L"")

如果您需要支持没有 v6 通用控件的系统,您可能可以找出哪些系统指标(或硬编码值) )通过使用系统指标值和系统 DPI 在工具栏控件中使用。

To disable visual styles for all controls, call SetThemeAppProperties(STAP_ALLOW_NONCLIENT) or SetThemeAppProperties(0) before you create your main window.

To disable visual styles per HWND you can call SetWindowTheme(hwndControl,L"",L"")

If you need to support systems without v6 common controls you can probably figure out which system metrics (or hardcoded values) are used in the toolbar control by playing with the system metric values and system DPI.

灰色世界里的红玫瑰 2025-01-10 22:12:49

通过正确使用 SetWindowTheme (以 L"" 作为参数)解决:我所要做的就是为我的应用程序创建的每个控件调用它。这感觉有点骇人听闻,但可以完成工作。

Solved by using SetWindowTheme (with L"" as parameters) properly: all I had to do was call it for each and every control my application creates. It feels hackish but gets the job done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文