关于透明窗口的一些收集
来源:互联网 发布:淘宝卖家互刷交流群 编辑:程序博客网 时间:2024/05/16 05:13
首先,用生成向导建立个基于对话框的程序框架,取名为PartTransparent
第二,重写BOOL CPartTransparentDlg::OnInitDialog(),也就是重写,对话框类的OnInitDialog()这个函数,在里面,return TRUE;前面加入下面的代码:
SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);HINSTANCE hInst = LoadLibrary(L"User32.DLL");if (hInst){typedef BOOL (WINAPI * MYFUNC)(HWND,COLORREF,BYTE,DWORD);MYFUNC fun = NULL;fun = (MYFUNC)GetProcAddress(hInst,"SetLayeredWindowAttributes");if (fun)fun(this->GetSafeHwnd(),0,128,2);FreeLibrary(hInst);}
其中fun(this->GetSafeHwnd(),0,128,2);修改窗口的透明度,值越接近255越不透明。
方法二:
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);
- 关于透明窗口的一些收集
- 关于透明窗口制造假象的精髓
- 关于转换的一些收集
- 关于Google的一些收集
- 关于抽象的一些收集
- 关于图片的处理的一些收集
- 关于窗口嵌入桌面及透明的注意事项
- 关于截屏截取不到透明窗口的问题
- 关于分层窗口文字输出透明的处理方法
- 关于路径资料的一些收集
- 关于垃圾收集的一些话
- 收集的一些关于ajax资料
- 关于ASPNET的一些缓存收集
- 关于插件的一些资料收集
- 关于垃圾收集的一些话
- 关于vs2005的一些资料收集
- 关于WorkFlow的一些文章连接收集
- 收集的一些关于CMarkUp介绍
- WCF中的Session和Instancing Management
- .net数据库连接池
- unable to find valid certification path to requested target'解决办法
- TCP/IP学习笔记(七)
- 杀毒软件的查杀病毒的原理以及木马、病毒的免杀伎俩
- 关于透明窗口的一些收集
- POJ 1775 Sum of Factorials 二分模板
- Flex+.Net 连续导入或导出 RemoteObject失效
- TCP/IP学习笔记(八)
- ZOJ 1457 Prime Ring Problem @Z
- CCS 3.3 编译 DM365 ubl
- Android Permission(授权)大全
- 递归算法详细分析
- fmt:formatDate标签的输出格式