C++ MFC功能区接口在本地化应用程序时导致断言失败
我有一个基于MFC的应用程序,使用Office2007功能区界面。MFC是静态链接的 我正在尝试添加日语本地化。我在一个单独的DLL中有本地化的资源。我正在C++ MFC功能区接口在本地化应用程序时导致断言失败,c++,localization,mfc,ribbon,assert,C++,Localization,Mfc,Ribbon,Assert,我有一个基于MFC的应用程序,使用Office2007功能区界面。MFC是静态链接的 我正在尝试添加日语本地化。我在一个单独的DLL中有本地化的资源。我正在InitInstance的开头加载资源DLL: VERIFY(hRes = LoadLibrary(_T("JapaneseLang.dll"))); if(hRes) AfxSetResourceHandle(hRes); 这会导致CMFCVisualManagerofice2007::OnUpdate系统颜色处的断言失败 #if
InitInstance
的开头加载资源DLL:
VERIFY(hRes = LoadLibrary(_T("JapaneseLang.dll")));
if(hRes)
AfxSetResourceHandle(hRes);
这会导致CMFCVisualManagerofice2007::OnUpdate系统颜色处的断言失败
#if !defined _AFXDLL
TRACE(_T("\r\nImportant: to enable the Office 2007 look in static link,\r\n"));
TRACE(_T("include afxribbon.rc from the RC file in your project.\r\n\r\n"));
ASSERT(FALSE);
#endif
但是我在DLL和EXE的rc文件中都包含了afxribbon.rc
我还发现了a和a的轮廓 现在我找到了错误的位置。这应该是新mfc的一个bug 版本 在CMFCVisualManagerofice2007中,当样式发生更改时 CMFCVisualManagerofice2007自动调用自由库的函数集样式 要释放dll,则会发生错误 现在,我从CMFCVisualManagerofice2007派生了一个类,并添加了一个 静态函数设置成员变量m_bAutoFreeRes,方法是 这样应用程序才能正确运行;见下文 CMFCVisualExtManagerofice2007类:公共 CMFCVisualManager 2007{ 宣布动态创建(CMFCVisualExtManager 2007)为公共: CMFCVisualExtManagerofice2007();虚拟 ~cmfcvisualexistmanageroffice2007() 静态void SetAutoFreeRes(BOOL bAutoFree=FALSE){mu bAutoFreeRes= 鲍托弗里;}}
但是我很难理解到底是什么导致了这个问题,以及这个解决方案是如何工作的。我也不确定这是否是一个正确的解决方案。有人知道这个问题的确切原因,以及解决方案是如何工作的吗?我知道了解决方案是如何工作的。每次调用
CMFCVisualManagerOffice2007::SetStyle
后,我需要将m_bAutoFreeRes
设置为false
class CMFCVisualExtManagerOffice2007 : public CMFCVisualManagerOffice2007
{
DECLARE_DYNCREATE(CMFCVisualExtManagerOffice2007)
public:
CMFCVisualExtManagerOffice2007();
virtual ~CMFCVisualExtManagerOffice2007();
static void SetAutoFreeRes(BOOL bAutoFree = FALSE)
{
m_bAutoFreeRes = bAutoFree;
}
};
然后在主题之间切换时
switch (m_nAppLook)
{
case ID_VIEW_APPLOOK_OFF_2007_BLUE:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_LunaBlue);
CMFCVisualExtManagerOffice2007::SetAutoFreeRes(FALSE);
break;
case ID_VIEW_APPLOOK_OFF_2007_BLACK:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);
CMFCVisualExtManagerOffice2007::SetAutoFreeRes(FALSE);
break;
case ID_VIEW_APPLOOK_OFF_2007_SILVER:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Silver);
CMFCVisualExtManagerOffice2007::SetAutoFreeRes(FALSE);
break;
case ID_VIEW_APPLOOK_OFF_2007_AQUA:
CMFCVisualManagerOffice2007::SetStyle (CMFCVisualManagerOffice2007::Office2007_Aqua);
CMFCVisualExtManagerOffice2007::SetAutoFreeRes(FALSE);
break;
}