STMCD
10-29-2010, 05:03 AM
Hello,
I'm migrating an application from Visual C-6.0 to Visual Studio 2010.
I also upgraded to Stingray Toolkit 10.4
From VC-6.0 to VS-2005: OK (many fixes but compiles and runs ok).
From VS-2005 to VS-2010: NOK: compiles but breaks at execution with an assertion violation:
_AFXWIN_INLINE int CMenu::GetMenuItemCount() const
{ ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemCount(m_hMenu); }
The m_hMenu is NULL because GetMenu() now always returns NULL
whereas it returned the right value with VS-2005.
In the InitInstance() function, I added for debug purpose many calls to GetMenu().
They all return NULL with VS-2010:
...
if (!m_pMainFrame || !m_pMainFrame->LoadFrame(IDR_MAINFRAME)) {
delete m_pMainFrame;
TRACE0 ("\nFailed to create mainframe");
return FALSE;
}
m_pMainWnd = m_pMainFrame;
m_pMainFrame->GetMenu(); /* VS2005, result == OK, is SECMDIFrameWnd::GetMenu() */
((CWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == NULL */
((CMainFrame*)m_pMainFrame)->GetMenu(); /* VS2005, result == OK */
((CMDIFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == NULL */
CMenu *pMenu = AfxGetMainWnd()->CWnd::GetMenu(); /* VS2005, result == NULL */
((CFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == NULL */
((SECMDIFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == OK */
((SECFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, Assertion violation */
/* computing pThis->GetMenuBar()->GetCurMenuID() as pThis->GetMenuBar() == NULL */
...
------------------------------------
I tried the demo application:
Stingray Studio 10.4\Samples\Toolkit\MFC\Docking\MenuBar\MdiAdv\md iadv10.sln
adding in "Mdiadv.cpp" the same GetMenu() calls than above. It always returns NULL with VS-2010.
Does someone have any idea to fix this issue ?
YG
I'm migrating an application from Visual C-6.0 to Visual Studio 2010.
I also upgraded to Stingray Toolkit 10.4
From VC-6.0 to VS-2005: OK (many fixes but compiles and runs ok).
From VS-2005 to VS-2010: NOK: compiles but breaks at execution with an assertion violation:
_AFXWIN_INLINE int CMenu::GetMenuItemCount() const
{ ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemCount(m_hMenu); }
The m_hMenu is NULL because GetMenu() now always returns NULL
whereas it returned the right value with VS-2005.
In the InitInstance() function, I added for debug purpose many calls to GetMenu().
They all return NULL with VS-2010:
...
if (!m_pMainFrame || !m_pMainFrame->LoadFrame(IDR_MAINFRAME)) {
delete m_pMainFrame;
TRACE0 ("\nFailed to create mainframe");
return FALSE;
}
m_pMainWnd = m_pMainFrame;
m_pMainFrame->GetMenu(); /* VS2005, result == OK, is SECMDIFrameWnd::GetMenu() */
((CWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == NULL */
((CMainFrame*)m_pMainFrame)->GetMenu(); /* VS2005, result == OK */
((CMDIFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == NULL */
CMenu *pMenu = AfxGetMainWnd()->CWnd::GetMenu(); /* VS2005, result == NULL */
((CFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == NULL */
((SECMDIFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, result == OK */
((SECFrameWnd*)m_pMainFrame)->GetMenu(); /* VS2005, Assertion violation */
/* computing pThis->GetMenuBar()->GetCurMenuID() as pThis->GetMenuBar() == NULL */
...
------------------------------------
I tried the demo application:
Stingray Studio 10.4\Samples\Toolkit\MFC\Docking\MenuBar\MdiAdv\md iadv10.sln
adding in "Mdiadv.cpp" the same GetMenu() calls than above. It always returns NULL with VS-2010.
Does someone have any idea to fix this issue ?
YG