I'm probably going to sound a bit like an idiot for not knowing any better, but frankly, I feel more inclined to blame the lack of help online in this matter.
I decided to create a new program using MFC (using SDI with View/Doc model), before I heard about the general opinion of MFC. So my app includes the main Frame window (CMainFrame
) and a child window (CMFCTestView
) and document (CMFCTestDoc
). Anyway, I want to have it so that when the user presses the "New" button on the toolbar, it gets rid of the child window that I currently have and replaces it with a new, fresh child window.
The code I currently have for this is:
void CMainFrame::OnFileNew()
{
#ifdef _DEBUG
_cprintf("New Game!");
#endif
Board b = Board(9, 9, 9);
theApp.RecieveBoard(b);
// Create(_T("CMFCTestDoc"), _T("CMFCTestView"), WS_CHILD | WS_VISIBLE,
// rectDefault, this);
CreateEx(NULL, _T("CMFCTestView"), _T("Minesweeper"), WS_CHILD | WS_VISIBLE, rectDefault, this, IDR_MAINFRAME, 0);
}
The small amount of information I could find online told me that CreateEx
was the function to use to create that new child window, so I tried to apply the example here to my application, but yet I get an error because it couldn't make the window. How am I actually supposed to accomplish what I'm trying to do?
Bonus: How do you pass along data to a new child window? Say you want the window to have certain variables/values set when it is first shown to the user. I tried to follow along with this answer, but got confused after deriving my own class based upon CMultiDocTemplate.