As u have told I have already intialized in OnCreate function of CMainFrame()
/////////////////////////////////////////////////////
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );
ASSERT( pApp->m_pszRegistryKey != NULL );
ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );
ASSERT( pApp->m_pszProfileName != NULL );
ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );
if( CMDIFrameWnd::OnCreate(lpCreateStruct) == -1 )
{
ASSERT( FALSE );
return -1;
}
VERIFY(
g_CmdManager->ProfileWndAdd(
pApp->m_pszProfileName,
GetSafeHwnd()
)
);
///////////////////////////////////////////////////////////////////////
When I debugged the function _UpdateMenuBar().
Note:Iam calling the _UpdateMenuBar in the OnCreate() function of the child frame.
<--- indicates debugger
/////////////////////////////////////
BOOL CMyMenuBar::_UpdateMenuBar( BOOL bDoRecalcLayout // = TRUE
)
{
SetButtons(); // remove all buttons
// remove all previously allocated command identifiers
// for menu buttons
VERIFY(
g_CmdManager->CmdRemoveByMask(
g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() ),<---
(DWORD)CExtCmdItem::STATE_MENUBAR_TMP ));
----->from GetSafeHwnd() the code jumps to the below function on debugging.
_AFXWIN_INLINE HWND CWnd::GetSafeHwnd() const
{ return this == NULL ? NULL : m_hWnd; }-->here the function is returning the NULL value instead of m_hWnd
I am getting the hWnd=0x00000000(NULL).I think due to the empty handle only iam getting this error.
----->from CExtCmdItem::STATE_MENUBAR_TMP the function jumps to
__EXT_MFC_SAFE_LPCTSTR CExtCmdManager::ProfileNameFromWnd(
HWND hWnd
)
{
ASSERT( hWnd != NULL );<---- from here the debugging jumps to AfxAssertFailedLine() function.
So Iam getting the error in the PeekMessage of the AfxAssertFailedLine() function.
What i should do to get the handle .
BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine)
{
#ifndef _AFX_NO_DEBUG_CRT
// we remove WM_QUIT because if it is in the queue then the message box
// won’t display
MSG msg;
BOOL bQuit = PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);//I have got the error in this line.
BOOL bResult = _CrtDbgReport(_CRT_ASSERT, lpszFileName, nLine, NULL, NULL);
if (bQuit)
PostQuitMessage(msg.wParam);
return bResult;
How to solve this problem?