Skip to main content
GameDev.net gamedev.net
🔒 Locked

MFC Initialisation structure problem

Started by Sfpiano Apr 14, 2005 at 1:08 AM 4 replies 350+ views
Original Post
Sfpiano
Sfpiano
I'm trying to create an editor in MFC with DirectX, however I'm run into a bit of a hurdle. I have my program set up as so: I have 4 viewing panes which inherit from my CView class, then I have all my DX stuff and the bulk of everything else in my CDocument class. MFC sets up everything with this nice little call here:

CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
	IDR_MAINFRAME,
	RUNTIME_CLASS(CDoc),
	RUNTIME_CLASS(CMainFrame),       // main SDI frame window
	RUNTIME_CLASS(CView));
The problem is that I need a way to pass the Main hWnd, which doesn't get created until CMainFrame is created, into CDoc, before CView gets called. That or think of a completely different way of organizing my program. Any suggestions, hints, solutions?
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
doho
doho
AfxGetMainWnd
Sfpiano
Sfpiano
Where would you suggest I call it, becuase that function won't return anything until CMainFrame gets created.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
ChaosEngine
ChaosEngine
why can't you just wait until the main frame is created to create the doc template.
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
Sfpiano
Sfpiano
Because MFC requires they be created in that order (Doc, Wnd, View).
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
doho
doho
Your initialization should be in CDocument::OnNewDocument resp. CView::OnInitialUpdate and then there should be no problem getting hold of the main window.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.