VC 窗口透明化

该博客介绍了如何使用Windows SDK中的SetLayeredWindowAttributes函数实现VC窗口的透明化效果,包括设置窗口的不透明度和透明色键。通过这个函数,可以成功地创建和管理具有透明特性的层叠窗口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

	//ModifyStyleEx(0, WS_EX_LAYERED|WS_EX_TRANSPARENT);  //窗口透明并且不接受鼠标消息
	ModifyStyleEx(0, WS_EX_LAYERED);  //窗口透明但接受鼠标消息
	SetLayeredWindowAttributes(0, 128, 2);  //第二个参数表示透明度
	//SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);


以下信息来自MSDN

 

CWnd::SetLayeredWindowAttributesVisual Studio 2010

Sets the opacity and transparency color key of a layered window.

BOOL SetLayeredWindowAttributes(
   COLORREF crKey,
   BYTE bAlpha,
   DWORD dwFlags
);
BOOL SetLayeredWindowAttributes(
   COLORREF crKey,
   BYTE bAlpha,
   DWORD dwFlags
);
Parameters
crKey

Pointer to a                    COLORREF value that specifies the transparency color key to be used when composing the layered window. All pixels painted by the window in this color will be transparent. To generate a                    COLORREF, use the RGB macro.                

bAlpha

Alpha value used to describe the opacity of the layered window. For more information, see the                    SourceConstantAlpha member of the                    BLENDFUNCTION structure. When                    bAlpha is 0, the window is completely transparent. When                    bAlpha is 255, the window is opaque.                

dwFlags

Specifies an action to take. This parameter can be one or more of the following values. For a list of possible values, see                   SetLayeredWindowAttributes.                

Return Value

Nonzero if the function succeeds; otherwise 0.

Remarks

This member function emulates the functionality of the function                SetLayeredWindowAttributes, as described in the Windows SDK.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值