简体   繁体   中英

How to create a window with transparent background?

Is possible/how to create a window without background or set her background transparent?

Another way than using a layered window , because controls will be loaded into the window.

My goal is to create a GUI with rounded borders, for that, I will load a picture as the background.

A layered window with the LWA_COLORKEY attribute is problematic if you want (Windows standard) child controls because there is no perfect color to pick as the transparent color.

However, layered windows have another mode; UpdateLayeredWindow . This function is perfect if you have an image (with alpha transparency) you want to use as the background. Just make sure the bitmap is pre-multiplied 32-bit ARGB before selecting it into the DC.

If for some crazy reason you can't use layered windows, the older option is SetWindowRgn .

The newer option is DirectComposition but I'm not sure if you are forced to set the layered style on the window.

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