-
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.
-
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.