CWnd::GetParent() returns a CWnd*. You can't cast this to a CDocument*, because CDocument and CWnd aren't related. Assuming that you're creating the dialog from your view class, you could create a new constructor for the dialog that allows you to pass a CDocument* into it. Then you could construct your dialog thus:


CMyDialog dlg(GetDocument());