How to achieve Steam-like window using winapi?

♀尐吖头ヾ 提交于 2019-12-04 12:30:00

问题


This is a screenshot of Steam's client window being resized.

Steam's client window has two cool features.

  1. Custom window which is very responsive.
  2. Cool glass resize effect, different from standard windows (Thought it might be a side effect strongly related to 1)

Let's say I wanna create similar window using winapi. How can I do it?

I don't ask about widget-management related stuff, but about technical winapi tricks.


回答1:


Basically, you can do almost anything with your window. But most of the tricks are to be implemented manually.

  1. 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 and WS_CAPTION when creating a WS_POPUP window. After that you will have to draw a border and a caption yourself. Handle WM_ERASEBKGND and WM_PAINT messages, draw background, menus, all as usual.
  2. 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 a WM_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.

In order to create a custom resizing border, you might find useful these functions: LoadCursor, SetCursor, MoveWindow.

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.



来源:https://stackoverflow.com/questions/15313403/how-to-achieve-steam-like-window-using-winapi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!