MDI 프로그램 시작 시 차일드 윈도우를 띄우지 않으려면

Category:
Author: zemna
Date: April 17, 2021
Share this:

+ MDI 프로그램 시작 시 차일드 윈도우를 띄우지 않으려면

MFC 애플리케이션 위저드는 MDI를 생성할 때 자동적으로 차일드 윈도우가

나타나도록 설계돼 있습니다. 이것은 CSomeApp(CWinApp의 자식 클래스)의

InitInstance()에서 정의돼 있기 때문입니다. 애플리케이션 위저드가 만들어 준

InitInstance()를 살펴 보면 다음과 같은 코드를 찾아 볼 수 있습니다.

BOOL CSomeApp::InitInstance() {

// ...

CCommandLineInfo cmdInfo;

ParseCommandLine(cmdInfo);

if(!ProcessShellCommand(cmdInfo))

return FALSE;

//...

}

앞 코드에서 볼 수 있는 CCommandLineInfo 클래스는 명령어 라인에서 입력된

쉘 명령어(일반적으로 오픈할 파일이름)에 관한 정보를 포함하고 있으므로 쉘

명령어가 없으면 새로운 빈 도큐먼트를 생성해 보여 주게 됩니다. 따라서

다음과 같이 코드를 변경해 주면 빈 도큐먼트를 생성해 보여 주는 것을

강제적으로 막을 수 있습니다.

BOOL CSomeApp::InitInstance() {

// ...

CCommandLineInfo cmdInfo;

ParseCommandLine(cmdInfo);

cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

if(!ProcessShellCommand(cmdInfo))

return FALSE;

// ...

}

여기서 CCommandLineInfo의 멤버 변수인 m_nShellCommand가 가질 수 있는

값은 다음과 같습니다.

enum{

FileNew,

FileOpen,

FilePrint,

FilePrintTo,

FileDDE,

FileNothing = -1

};

이중 FileNothing이 MDI 애플리케이션이 생성될 때 새로운 도큐먼트를 생성해

주는 것을 막아 주는 값입니다.

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's connect and create
something awesome together!
2023 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram