工作问题积累(八)SetLayeredWindowAttributes(设置透明窗体)

注意:SetLayeredWindowAttributes不能用于WS_CHILD属性的窗体,

WS_POPUP属性的透明窗口设置代码如下:

<span style="font-size:14px;">void CommonWnd::SetTransparentwnd()
{

 SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,
   GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
 HINSTANCE hInst = LoadLibrary("User32.DLL");
   if(hInst)
 {

 //方法2
 SetLayeredWindowAttributes(RGB(188,217,213),200,2);
 FreeLibrary(hInst);
 }
 Invalidate(TRUE);
}
</span>


 

调用该函数即可!

附上:(MSDN查询结果)

Also by default, a child window (that is, one created with the WS_CHILD style and with a valid
parent hWnd parameter in the call to CreateWindow or CreateWindowEx) has the same layout as its parent.
To disable inheritance of mirroring to all child windows, specify WS_EX_NOINHERITLAYOUT in the call
to CreateWindowEx. Note, mirroring is not inherited by owned windows (those created without the
WS_CHILD style) or those created with the parent hWnd parameter in CreateWindowEx set to NULL. To
disable inheritance of mirroring for an individual window, process the WM_NCCREATE message with
GetWindowLong and SetWindowLong to turn off the WS_EX_LAYOUTRTL flag. This processing is in addition
to whatever other processing is needed. The following code fragment shows how this is done.
SetWindowLong (hWnd,
GWL_EXSTYLE,
GetWindowLong(hWnd,GWL_EXSTYLE) & ~WS_EX_LAYOUTRTL))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值