# MFC MDI question

## Recommended Posts

I'm writing a map editor and already have the view structure set up, but I want all the data to be handled by the document structure. How do I pass the document data to the view so the map can be rendered as well as serialized through the document? My code so far: http://www.venosoft.com/uploads/njedit.zip I know it isn't much, but I don't want to get so deep that it's impossible to change.

##### Share on other sites
Well, when your CMyView::OnDraw(CDC * pDC) function gets called, you can just do CMyDocument * Document = GetDocument();. IIRC the MFC app wizard generates this for you, something like this:
void CMyView::OnDraw(CDC* pDC){	CMyDoc* pDoc = GetDocument();	ASSERT_VALID(pDoc);}

Then you just draw whatever from the data in pDoc to pDC.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978342

• 10
• 12
• 22
• 13
• 33