CMDIFrameWnd and Create

This is a discussion on CMDIFrameWnd and Create within the Windows Programming forums, part of the Platform Specific Boards category; Hi, this code is not working, why? Code: #include <afxwin.h> #include <afxtempl.h> #include "resource.h" class CTestXApp : public CWinApp { ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    24

    CMDIFrameWnd and Create

    Hi,

    this code is not working,
    why?

    Code:
    #include <afxwin.h>	
    #include <afxtempl.h> 
    
    #include "resource.h"
    
    
    class CTestXApp : public CWinApp
    {
    	public:
    	
    	BOOL InitInstance()
    	{	
    		
    		/// works with this: CFrameWnd* pMainFrame = new CFrameWnd; 
    
    		CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
    
    		m_pMainWnd = pMainFrame;
    		pMainFrame->Create (NULL, "My App");		
    		pMainFrame->ActivateFrame();
    
    		return TRUE;
    	}
    };
    
    
    CTestXApp theApp;
    If executed, appears "Assertion Failed" message.

    I really appreciate If somebody gives a little simple (very simple) sample of creating CMDIFrame and blank child windows.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    I looked in winmdi.cpp and now I know why this "Assertion Failed" appears.
    CMDIFrameWnd must have menu with submenu and at least with two items.

    I made menu (resource) and called LoadFrame() method instead Create():
    Code:
    CMDIFrameWnd->LoadFrame(IDR_MYMENU);
    Now it works.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21