MFC实现对话框透明显示:对话框透明而上面的文字不透明

来源:互联网 发布:青岛seo服务外包 编辑:程序博客网 时间:2024/05/29 04:35

在**Dlg.cpp的OnInitDialog()函数中添加下面代码即可:

SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);           HINSTANCE hInst = LoadLibrary("User32.DLL");               if(hInst)               {           typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD);           MYFUNC       fun = NULL;       //取得SetLayeredWindowAttributes函数指针           fun=(MYFUNC)GetProcAddress(hInst,   "SetLayeredWindowAttributes");       COLORREF   colorkey=14215660; if (fun )fun(this->GetSafeHwnd(),colorkey,0,1);           FreeLibrary(hInst);               }       

当然,这样标题栏不会隐藏,要想使标题栏也隐藏,再另行设置即可!

源码下载(不是我写的):

http://www.pudn.com/downloads91/sourcecode/windows/dialog/detail348712.html

原创粉丝点击