您当前的位置: 首页 > 

VC实现透明背景和半透明图片

发布时间:2012-06-09 10:51:00 ,浏览量:0

1.如何将对话框客户区的背景设成透明的? crybird (寒号鸟) http://expert.csdn.net/Expert/topic/2172/2172079.xml 描述:如题。客户区的背景能设成透明的么?如果有时间,非客户区的隐藏也讲讲啦! 回复人: bcpl(我是宇宙中的一粒沙子) BOOL CALLBACK EnumChildFunc(HWND hwnd, LPARAM lParam) { CRgn *pRgn = (CRgn*)lParam; CRect rcChild; ::GetWindowRect(hwnd, rcChild); CRgn rgnChild; CRgn rgnCopy; rgnCopy.CreateRectRgn(0, 0, 1, 1); rgnCopy.CopyRgn(pRgn); rgnChild.CreateRectRgn(rcChild.left, rcChild.top, rcChild.right, rcChild.bottom); pRgn->CombineRgn(&rgnCopy, &rgnChild, RGN_OR); return TRUE; } int SetBackTransparent(CWnd *pWnd, BOOL bClientOnly = TRUE) { CRgn rgn; if(bClientOnly) { CRgn rgnWindow, rgnClient; CRect rcWindow, rcClient, rcRgn; pWnd->GetWindowRect(rcWindow); pWnd->GetClientRect(rcClient); pWnd->ClientToScreen(rcClient); rgnWindow.CreateRectRgn(rcWindow.left, rcWindow.top, rcWindow.right, rcWindow.bottom); rgnClient.CreateRectRgn(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); rgn.CreateRectRgn(0, 0, 1, 1); rgn.CombineRgn(&rgnWindow, &rgnClient, RGN_DIFF); } else { rgn.CreateRectRgn(0, 0, 0, 0); } ::EnumChildWindows(pWnd->GetSafeHwnd(), (WNDENUMPROC)EnumChildFunc,(LPARAM)&rgn); return pWnd->SetWindowRgn(rgn, TRUE); } 调用办法: 在CYourDialog::OnInitDialog里加上 SetBackTransparent(this); 如果要连非客户区都透明,用 SetBackTransparent(this, FALSE); 版主点评: 高手。 //--------------------------------------------------------------------------- http://expert.csdn.net/Expert/topic/2422/2422164.xml 主  题: 如何在一个背景图像上,做半透明的图? 作  者: DMC (DMC) 描述: 如何在一个背景图像上,做半透明的图。我想实现在一个地图上显示半透明的数据信息,类似天气预报中等压图的处理。如何才能实现这个背景图和最上层图的相互映射,完成半透明的效果? 回复人: Raxxxer(Jasmine Hellstorm) 你可以使用windows的一个api AlphaBlend,用法和BitBlt差不多: BLENDFUNCTION bf; bf.AlphaFormat=0; bf.BlendFlags=0; bf.BlendOp=AC_SRC_OVER; bf.SourceConstantAlpha=100;//透明度0-255 AlphaBlend(hBackDC,0,70,73,20,hMaskDC,0,0,73,20,bf); 不可以在WindowsCE里用 #include //还要在Project -- setting -- link 里连接上msimg32.lib
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    110069博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.3386s