MDI로 프로젝트를 기본으로 만들고 나면 기본으로 자식창이 생겨난다.. 이럴때, 자식창을 기본으로 만들고 싶지 않을때는 어떻게 하면 될까 찾아보니 MSDN에 다음과 같이 나와 있다.

아래 소스에서 파란색 부분을 추가하면 기본적으로 MDI 프레임만 나타난 상태의 창을 만들 수가 있다.


[출처 : http://support.microsoft.com/kb/141725] ]


열거형 값이 CCommandLineInfo::FileNothing CCommandLineInfo::m_nShellCommand 온라인 설명서 없습니다. 그러나 해당 정의가 헤더 파일 \Msdev\Mfc\Include\Afxwin.h 찾을 수 있습니다.

시작할 때 새 MDI 자식 창이 만들어지지 않도록 다음 예제 코드를 사용할 수 있도록 모든 CWinApp 파생 클래스의 InitInstance()에 의해 ProcessShellCommand() 함수가 호출됩니다.


예제 코드

BOOL CMyWinApp::InitInstance()
    {
    ...

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);

    // Don't display a new MDI child window during startup
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
      cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;

    ...
    }
		


+ Recent posts