1 Visual C Multiple Document Interface Application
2 MDI Multiple Document Interface Application 여러 개의 다큐먼트를 처리할 수 있도록 만들어진 프로그램 SDI Application
3 MDI 하나의 프로그램에서 여러 개의 문서를 동시에 열어 놓고 작업
4 MDI 를 위한 MFC Class SDIMDI
5 SDI vs. MDI CMDIFrameWnd 와 CMDIChildWnd 클래스는 CFrameWnd 클래스에서 상속 프레임윈도우의 기능 가짐 CMDIFrameWnd 클래스에는 CMDIChildWnd 클래스를 관리 CMDIChildWnd 클래스에는 CMDIFrameWnd 의 안쪽에 들어 가서 클래스의 관리를 받음
6 MDI Application 만들기
7 CWinApp 파생클래스의 InitInstance( ) SDI BOOL CTestApp::InitInstance() { CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CTestDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CTestView)); AddDocTemplate(pDocTemplate); return TRUE; }
8 CWinApp 파생클래스의 InitInstance( ) MDI BOOL CTestApp::InitInstance() { CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_TESTTYPE, RUNTIME_CLASS(CTestDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CTestView)); AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; return TRUE; }
9 MDI Resource
10 Resource
11 MDI – Test Project 참고 App. Wizard 가 만들어준 MDI Application : Compile & 실행 최초에 child window 가 하나 열림
12 MDI – Test Project 참고 BOOL CTestApp::InitInstance() { // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; // Turn off default OnFileNew() call cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; } // Compile & 실행
13 MDI – Test Project 참고
14 MDI – Test Project 참고 class CCommandLineInfo : public CObject { …… enum { FileNew, FileOpen, FilePrint, FilePrintTo, FileDDE, AppUnregister, FileNothing = -1 } m_nShellCommand; // not valid for FileNew CString m_strFileName; …… };
15 MDI – Test Project 참고 cmdInfo.m_nShellCommand=CCommandLineInfo::FileNew; //Call CWinApp:: OnFileNew() – Default cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; // Do nothing. cmdInfo.m_nShellCommand=CCommandLineInfo::FileOpen; //Call OpenDocumentFile(cmdInfo.m_strFileName)
16 MDI – MDIDraw Project 참고 CCommandLineInfo cmdInfo; cmdInfo.m_nShellCommand=CCommandLineInfo::FileOpen; cmdInfo.m_strFileName="Test.drw"; ParseCommandLine(cmdInfo);
17 Visual C MDI Application 기본적인 구조 Command Line 의 해석