问题
This is a screenshot of Steam's client window being resized.
Steam's client window has two cool features.
- Custom window which is very responsive.
- 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.
- 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.
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