Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » MainFrame not loaded Collapse All
Subject Author Date
Anand Tripathi Sep 22, 2008 - 2:43 AM

Hi All


I am developing the project. it is MDI based derived from CScrollView class. i am giving some code frame mainframe class..


if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)

  return -1;


 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’) );

 

 ASSERT( pApp->m_pszProfileName != NULL ); 

 g_CmdManager->ProfileSetup(

  pApp->m_pszProfileName,

  GetSafeHwnd()

  );

 

VERIFY(

  g_CmdManager->UpdateFromMenu(

  pApp->m_pszProfileName,

  IDR_MAINFRAME

  )

  );




 VERIFY(

        g_CmdManager->UpdateFromMenu(

        pApp->m_pszProfileName,

        IDR_MYPAINTYPE

                  )

      );

 VERIFY(

        g_CmdManager->UpdateFromToolBar(

        pApp->m_pszProfileName,

        IDR_TOOLBAR2

        )

        );

 




 if( !m_wndToolBar.Create(

  NULL,

  this,

  AFX_IDW_TOOLBAR

  )

  ||

  !m_wndToolBar.LoadToolBar(IDR_TOOLBAR)

  )

 {

  TRACE0("Failed to create toolbar\n");

  return -1;      // fail to create

 }


and in CPP class in InitInstance method...


AfxEnableControlContainer ();

  // <dave> dump memory leaks

 #ifdef _DEBUG

  _CrtDumpMemoryLeaks();

  _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

 #endif

  // Standard initialization

 #ifdef _AFXDLL

  Enable3dControls();   // Call this when using MFC in a shared DLL

 #else

  Enable3dControlsStatic(); // Call this when linking to MFC statically

 #endif

  

  // Change the registry key under which our settings are stored.

  // TODO: You should modify this string to be something appropriate

  // such as the name of your company or organization.

  SetRegistryKey(_T("Local AppWizard-Generated Applications"));

 // SetRegistryKey( _T("NetSoft") );

  SetupUiAdvancedOptions();

  LoadStdProfileSettings(5);

  

  // Register the application’s document templates.  Document templates

  //  serve as the connection between documents, frame windows and views.


  CMultiDocTemplate* pDocTemplate;

  pDocTemplate = new CMultiDocTemplate(

   IDR_MYPAINTYPE,

   RUNTIME_CLASS(CMyPaintDoc),

   RUNTIME_CLASS(CChildFrame),       // main SDI frame window

   RUNTIME_CLASS(CMyPaintView));

   demoTemplate = pDocTemplate;

   m_DocTemplate = pDocTemplate;//test

   AddDocTemplate(pDocTemplate);

    

   

 

   

    CMainFrame* pMainFrame = new CMainFrame;

    if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE;

    m_pMainWnd = pMainFrame;


when i debug my application i found  null handler of mainframe exact this line if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; i am using these classes


CExtToolControlBar    m_wndToolBar;

 CExtMenuControlBar    m_wndMenuBar;

  CExtStatusControlBar  m_wndStatusBar;


can any body heelp me.


               thanks in advanced.

Technical Support Sep 24, 2008 - 5:10 AM

We believe the problem may be to do with something that has yet not discussed in this forum thread. Did you modify your project settings with changing options like structure members alignment or calling convention? In any case, you can send us your real or test project to the support mail box at this web site so we can find out what’s wrong.

Technical Support Sep 22, 2008 - 7:47 AM

Please set a break point at the beginning of the CMainFrame::OnCreate() method and debug it step by step. You will be able to detect what is not created successfully and why the entire main frame window is not created?

Anand Tripathi Sep 23, 2008 - 1:58 AM

Its ok. I know it. But when my debug goes to the


VERIFY(

        g_CmdManager->UpdateFromToolBar(

        pApp->m_pszProfileName,

        IDR_TOOLBAR2

        )

        );


 


it send Assertion due to mainframe handler as i think


 


and in this line


 




 if( !m_wndToolBar.Create(

  NULL,

  this,

  AFX_IDW_TOOLBAR

  )

  ||

  !m_wndToolBar.LoadToolBar(IDR_TOOLBAR)

  )

 {

  TRACE0("Failed to create toolbar\n");

  return -1;      // fail to create

 }


 


it shows null handler of m_wndToolBar.


                                                                    thanks.