예제 #1
0
void CMainFrame::OnFileNew() 
{
	BOOL bMaximized = FALSE;
	// creates a new child window, maximized if active child is maximized
	CChildFrame* pActiveChild = (CChildFrame*) MDIGetActive(&bMaximized);
	CChildFrame* pChild = new CChildFrame();
	pChild->LoadFrame(IDR_EX22CTYPE,
		WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW |
		(bMaximized ? WS_MAXIMIZE : 0), this);

	CString strTitle;
	strTitle.Format("Child Window %d", m_nChild++);
	pChild->SetWindowText(strTitle);
}
예제 #2
0
CChildFrame* CChildFrame::CreateNewFrame( CStaticDoc* pStaticDoc )
{
	if (pStaticDoc != NULL)
		ASSERT_VALID(pStaticDoc);
	// create a frame wired to the specified document

	ASSERT( pStaticDoc->GetIDResource() != 0); // must have a resource ID to load from
	CCreateContext context;
	context.m_pCurrentFrame = NULL;
	context.m_pCurrentDoc = NULL;		//pStaticDoc;
	context.m_pLastView = NULL;
	context.m_pNewViewClass = NULL; // pViewClass if this is set, a view will be created!
	context.m_pNewDocTemplate = NULL;

	CRuntimeClass* pFrameClass = RUNTIME_CLASS(CChildFrame);

	CChildFrame * pFrame = (CChildFrame*)pFrameClass->CreateObject();
	if (pFrame == NULL)
	{
		TRACE1("Warning: Dynamic create of frame %hs failed.\n",
			pFrameClass->m_lpszClassName);
		return NULL;
	}
	ASSERT_KINDOF(CChildFrame, pFrame);

	// create new from resource
	if (!pFrame->LoadFrame( pStaticDoc->GetIDResource(),
			WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,   // default frame styles
			AfxGetMainFrame(), &context))
	{
		TRACE0("Warning: Couldn't create a child frame.\n");
		// frame will be deleted in PostNcDestroy cleanup
		return NULL;
	}

	// it worked !
	return pFrame;
}