From: Sunny on
I write a program in vc++ 2008,and i want to make it support multiple
language. so i write a dll with all the resource build in it ,then i use the
API

function : LoadLibrary to Load the resource dll. last i use
AfxSetResourceHandle(hCurrLanguageInstanceHandle);still now the application
can run.

but when i change the visual style. for example i change the style to office
2007(blue style), the application will stop at line 7 below..

can someone help me. thanks !!!!!!

1 CTagManager tm;
2 if (!tm.LoadFromResource(GetStyleResourceID(m_Style), AFX_RT_STYLE_XML))
3 {
4 #if !defined _AFXDLL
5 TRACE(_T("\r\nImportant: to enable the Office 2007 look in static
link,\r\n"));
6 TRACE(_T("include afxribbon.rc from the RC file in your
project.\r\n\r\n"));
7 ASSERT(FALSE);
8 #endif
9 if (hinstResOld != NULL)
10 {
11 AfxSetResourceHandle(hinstResOld);
12 }
13
14 return;
15 }


From: Ajay Kalra on
You said its a DLL but the TRACE indicates that you are static linking. What
sort of DLL is it, MFC Extension or a Regular DLL?

--
Ajay

"Sunny" <sound_of_nature(a)hotmail.com> wrote in message
news:OXSc0z3xIHA.4952(a)TK2MSFTNGP05.phx.gbl...
>I write a program in vc++ 2008,and i want to make it support multiple
>language. so i write a dll with all the resource build in it ,then i use
>the API
>
> function : LoadLibrary to Load the resource dll. last i use
> AfxSetResourceHandle(hCurrLanguageInstanceHandle);still now the
> application can run.
>
> but when i change the visual style. for example i change the style to
> office 2007(blue style), the application will stop at line 7 below..
>
> can someone help me. thanks !!!!!!
>
> 1 CTagManager tm;
> 2 if (!tm.LoadFromResource(GetStyleResourceID(m_Style),
> AFX_RT_STYLE_XML))
> 3 {
> 4 #if !defined _AFXDLL
> 5 TRACE(_T("\r\nImportant: to enable the Office 2007 look in static
> link,\r\n"));
> 6 TRACE(_T("include afxribbon.rc from the RC file in your
> project.\r\n\r\n"));
> 7 ASSERT(FALSE);
> 8 #endif
> 9 if (hinstResOld != NULL)
> 10 {
> 11 AfxSetResourceHandle(hinstResOld);
> 12 }
> 13
> 14 return;
> 15 }
>

From: Sunny on
Regular DLL

Now i find the error location.
this shoule be a bug of new mfc version.

In the CMFCVisualManagerOffice2007 ,when the style is changing , the
function SetStyle of CMFCVisualManagerOffice2007 auto call FreeLibrary to
free the dll, so the error happend.

Now i derived a class from CMFCVisualManagerOffice2007
and add a static function to set the member variable m_bAutoFreeRes , by
doing this the application can run correctly; see bellow.

class CMFCVisualExtManagerOffice2007 : public CMFCVisualManagerOffice2007
{
DECLARE_DYNCREATE(CMFCVisualExtManagerOffice2007)
public:
CMFCVisualExtManagerOffice2007();
virtual ~CMFCVisualExtManagerOffice2007();

static void SetAutoFreeRes(BOOL bAutoFree = FALSE)
{
m_bAutoFreeRes = bAutoFree;
}
};


From: David Ching on
"Sunny" <sound_of_nature(a)hotmail.com> wrote in message
news:OXSc0z3xIHA.4952(a)TK2MSFTNGP05.phx.gbl...
> 4 #if !defined _AFXDLL
> 5 TRACE(_T("\r\nImportant: to enable the Office 2007 look in static
> link,\r\n"));
> 6 TRACE(_T("include afxribbon.rc from the RC file in your
> project.\r\n\r\n"));
> 7 ASSERT(FALSE);
> 8 #endif

Well, did you include afxribbon.rc in your new resource .rc file? When
creating the new .rc file, I would start with a copy of your existing one
and then change the resources inside, so that important things like
including of things like afxribbon.rc remain intact.

-- David


From: David Ching on
"Sunny" <sound_of_nature(a)hotmail.com> wrote in message
news:uihtiw4xIHA.420(a)TK2MSFTNGP02.phx.gbl...
> Regular DLL
>
> Now i find the error location.
> this shoule be a bug of new mfc version.
>
> In the CMFCVisualManagerOffice2007 ,when the style is changing , the
> function SetStyle of CMFCVisualManagerOffice2007 auto call FreeLibrary
> to free the dll, so the error happend.
>

I don't see how freeing your resource dll caused an error. If your resource
dll is similar to the one it replaces, it shouldn't matter that it is freed.

-- David


 |  Next  |  Last
Pages: 1 2
Prev: Memory leaks
Next: Disk or network error