MFC去掉win7玻璃效果

在MainFrame的OnCreate中添加以下代码

if (CWnd::OnCreate(lpCreateStruct) == -1) return -1;

HINSTANCE hInstance = LoadLibrary(_T("UxTheme.dll"));
if (hInstance)
{
typedef HRESULT (WINAPI *PFUN_SetWindowTheme)(HWND,LPCTSTR,LPCTSTR);
PFUN_SetWindowTheme pFun = (PFUN_SetWindowTheme)GetProcAddress(hInstance,"SetWindowTheme");
if (pFun)
{
pFun(m_hWnd,_T(""),_T(""));
}
FreeLibrary(hInstance);
}
hInstance = LoadLibrary(_T("dwmapi.dll"));
if (hInstance)
{
typedef HRESULT (WINAPI *TmpFun)(HWND,DWORD,LPCVOID,DWORD);
TmpFun DwmSetWindowAttributeEX = (TmpFun)::GetProcAddress(hInstance,"DwmSetWindowAttribute");
if (DwmSetWindowAttributeEX)
{
DWORD dwAttr = 1;
DwmSetWindowAttributeEX(GetSafeHwnd(),2,&dwAttr,4);
}
FreeLibrary(hInstance);
}

 

添加WM_NCACTIVE消息函数
BOOL CMainFrame::OnNcActivate(BOOL bActive)
{
BOOL bRet = CWnd::OnNcActivate(bActive);
SendMessage(WM_NCPAINT,0,0);
Invalidate();
return bRet;
}

posted on 2014-04-26 20:06  XCoderLiu  阅读(304)  评论(0编辑  收藏  举报

导航