简体   繁体   中英

How to create a child window is transparent and the parent window is not transparent?

I want to create a window with two child windows. Only the background of the top child window is transparent. I can directly see the background of the parent window and not the content of other child windows.Like the picture, A is parent, B is child 1, C is child 2.The background of child 2 is the same as parent. enter image description here

Aam,

You paint background on child window by yourself. There is method OnPaint (in MFC) or message WM_PAINT. And you should draw transparent background (it means to draw nothing). Does it work?

If you use non-standart framework to create windows, you should specify background is painted programmatically.

A few options to experiment with:

If in your open source UI framework you can remove the WM_PAINT handler entry in the DefWindowProc then you could do that.

Handle the WM_PAINT message yourself and do nothing in the handler except clear any flag that indicates that the client area needs to be re-drawn. You'll need to find something equivalent to ValidateRect.

Both of these methods MIGHT cause non client areas like the window frame to artifact within the client area as you move window C around but I can't be sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM