WIN7或者WIN8上边框的异常问题的解决攻略

//主要两个步骤:
//第一个步骤就是在CMainFrame::OnCreate里面增加

  HINSTANCE hInst = LoadLibrary(_T("UxTheme.dll"));

    if (hInst)

    {

        typedef HRESULT (WINAPI *PFUN_SetWindowTheme)(HWND, LPCTSTR, LPCTSTR);

        PFUN_SetWindowTheme pFun = (PFUN_SetWindowTheme)GetProcAddress(hInst, "SetWindowTheme");

        if (pFun)

        {

            pFun(m_hWnd, _T(""), _T("")); //去掉xp主体

        }

        FreeLibrary(hInst);

    }



    hInst = LoadLibrary(_T("dwmapi.dll"));

    if (hInst)

    {

        typedef HRESULT (WINAPI * TmpFun)(HWND,DWORD,LPCVOID,DWORD);

        TmpFun DwmSetWindowAttributeEX = (TmpFun)::GetProcAddress(hInst, "DwmSetWindowAttribute");

        if (DwmSetWindowAttributeEX)

        {

            DWORD dwAttr = 1;

            DwmSetWindowAttributeEX(GetSafeHwnd(), 2, &dwAttr, 4); //去掉vista特效

        }

        FreeLibrary(hInst);

    }

//然后就是添加WM_NCACTIVATE添加消息响应函数:

BOOL CMainFrame::OnNcActivate(BOOL bActive)

{

    BOOL bRet = CWnd::OnNcActivate(bActive);

    SendMessage(WM_NCPAINT, 0, 0);

    Invalidate();

    return bRet;

}

 

你可能感兴趣的:(win7)