如何使用winapi实现类似Steam的窗口? [英] How to achieve Steam-like window using winapi?
问题描述
这是正在调整 Steam 客户端窗口大小的屏幕截图.
This is a screenshot of Steam's client window being resized.
Steam 的客户端窗口有两个很酷的功能.
Steam's client window has two cool features.
- 响应迅速的自定义窗口.
- 酷玻璃调整大小效果,与标准窗口不同(认为可能是与 1 密切相关的副作用)
假设我想使用 winapi 创建类似的窗口.我该怎么做?
Let's say I wanna create similar window using winapi. How can I do it?
我问的不是小部件管理相关的东西,而是技术 winapi 技巧.
I don't ask about widget-management related stuff, but about technical winapi tricks.
推荐答案
基本上,您几乎可以对窗口执行任何操作.但大部分技巧都需要手动实现.
Basically, you can do almost anything with your window. But most of the tricks are to be implemented manually.
- 我不知道什么是非常敏感".如果您的意思是窗口没有标准边框,那么实现起来很容易:创建
WS_POPUP
窗口时不要指定WS_BORDER
和WS_CAPTION
.之后,您必须自己绘制边框和标题.处理WM_ERASEBKGND
和WM_PAINT
消息,绘制背景,菜单,一切照常. - 在我看来,这种效果更像是一个错误.它是这样发生的:窗口被调整大小,它得到一个
WM_SIZE
消息,处理它,Windows 发送一个窗口忽略的WM_ERASEBKGND
消息.因此,系统在尚未填充新窗口图像的新窗口框架周围绘制新阴影.在这里,我们得到了这种很酷的玻璃效果:带有窗户空气阴影的窗户的旧图像.您可以尝试禁用窗口阴影并查看此效果.
- What is 'very responsive' I don't know. If you mean that the window has no standart border, it is easy to implement: do not specify
WS_BORDER
andWS_CAPTION
when creating aWS_POPUP
window. After that you will have to draw a border and a caption yourself. HandleWM_ERASEBKGND
andWM_PAINT
messages, draw background, menus, all as usual. - This effect seems to me more like a bug. It happens this way: the window is resized, it gets a
WM_SIZE
message, processes it, Windows sends aWM_ERASEBKGND
message which the window ignores. Thus, the system draws a new shadow around new window frame which is not yet filled with new window image. And here we get this cool glass effect: old image of underlaying windows with a windows aero shadow. You can try to disable windows shadows and look at this effect.
为了创建自定义大小调整边框,您可能会发现这些函数很有用:LoadCursor
、SetCursor
、MoveWindow
.
In order to create a custom resizing border, you might find useful these functions: LoadCursor
, SetCursor
, MoveWindow
.
为了绘制自定义边框,您可以使用标准 GDI 函数.您也可以创建一些子窗口并将绘图委托给它们.这是winapi的基础.
In order to draw your custom borders, you can use standart GDI functions. Also you can create a handful of child windows and delegate drawing to them. This is basics of winapi.
这篇关于如何使用winapi实现类似Steam的窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!