如何在 C++ 中更改窗口样式/主题 [英] How to change window style/theme in c++

查看:51
本文介绍了如何在 C++ 中更改窗口样式/主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法来自定义窗口样式,例如 Steam 或 Spotify.我不想有乏味的 Windows(或任何其他操作系统)外观.这可以用 Qt 或 WinApi 完成吗?我是否需要 DirectX 或 OpenGL 来执行此操作?

I need an approach how to customize the window style like Steam or Spotify. I don't want to have the boring Windows (or any other OS) look. Can that be done with Qt or the WinApi? Do I need DirectX or OpenGL for doing that?

最好的问候

推荐答案

是的,您可以使用 WinAPI 来完成.您关心的主要信息是 WM_NCPAINT.这就是需要绘制窗口的非客户区域(例如框架和标题栏)时发送的内容.

Yes, you can do it with the WinAPI. The primary message you care about is WM_NCPAINT. That's what's sent when the non-client areas of a window (e.g., the frame and title bar) need to be painted.

请注意,默认情况下,非客户区的渲染由桌面窗口管理器 (DWM) 处理.如果您要处理自己的绘图,通常需要使用 DwmSetWindowAttribute 显式启用/禁用它.否则,您可能会出现奇怪的症状(例如,如果尝试切换回库存"框架等,它可能不会注意到"并重新开始绘制框架).

Note that by default, rendering of the non-client areas is handled by the desktop window manager (DWM). If you're going to handle your own drawing, you usually want to explicitly enable/disable that with DwmSetWindowAttribute. Otherwise, you can get strange symptoms (e.g., if try to switch back to "stock" frames and such, it may not "notice" and start drawing your frame again).

Microsoft 有一篇MSDN 上的文章,其中包含有关执行此操作的更多详细信息与 DWM 结合使用.

Microsoft has an article on MSDN with more details on doing this in conjunction with DWM.

这篇关于如何在 C++ 中更改窗口样式/主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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