如何更改对话框的不透明度? [英] How Can I Change the Opacity of a Dialog?

查看:78
本文介绍了如何更改对话框的不透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对话框,用于在:: OnCreate中创建一个窗口.我想更改该对话框的不透明度,而不是窗口.我也将此代码放在:: Oncreate中(在创建CWnd的代码之前):

I have a Dialog that creates a window in ::OnCreate. I want to change the opacity of this dialog not the window. I Put this code in ::Oncreate too (before the code creating CWnd):

LONG ExtendedStyle = GetWindowLong( GetSafeHwnd(), GWL_EXSTYLE );
SetWindowLong( GetSafeHwnd(), GWL_EXSTYLE, ExtendedStyle | WS_EX_LAYERED );
SetLayeredWindowAttributes( 0, 100, LWA_ALPHA );



该代码使Dialog和Window都透明.



this code makes both Dialog and Window transparent.
How can I set this attribute in my desired way?

推荐答案

尝试这种方式:

Try it this way:

ModifyStyleEx(0, WS_EX_LAYERED);
SetLayeredWindowAttributes(0, 255 * 0.50, LWA_ALPHA);


这篇关于如何更改对话框的不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆