728x90
300x250

[MS C++(MFC)] SDI(단일 문서)에서 자녀 다이얼로그(Child dialog in single document interface (SDI)


MFC의 SDI를 다루는 방법 중 자녀 다이얼로그 제어에 대해서 소개합니다.
(This section introduces the child dialog control method of handling MDI's SDI.)

작성 환경은 Visual Studio 2019, Windows 10 1909에서 진행하였습니다.
(The authoring environment was in Visual Studio 2019, Windows 10 1909.)

 


1. MFC 프로젝트 생성하기(Creating an MFC Project)

 

"단일 문서"를 선택하고 아래의 그림처럼 설정합니다.
(Select "Single Document" and set it as shown below.)

 

다음을 누릅니다.(Click Next.)

 

 

다음을 누릅니다.(Click Next.)

 

 

다음을 누릅니다.(Click Next.)

 

 

"체크 박스"를 위의 그림처럼 해줍니다.(Do a "check box" as shown above.)

 

 

마침을 클릭합니다.(Click Finish.)

"로컬 Windows 디버거" 또는 "Ctrl + F5키"를 누르면 아래의 창이 뜹니다.
(Press "Local Windows Debugger" or "Ctrl + F5" to bring up the window below.)

 

 


2. MFCFormView.rc에서 다이얼로그 생성하기(Creating a dialog in MFCFormView.rc)

 

다이얼로그를 하나 생성합니다. (Create one dialog.)

 

 

다이얼 로그를 생성하면 아래의 그림처럼 생성됩니다.(When you create a dial log, it is created as shown below.)

 

 

그리고 다이얼 로그를 오른쪽 버튼 한 후, 클래스 추가를 클릭합니다.
(Then right-click on the dialog and click Add Class.)

 

 

Dlg1으로 해도 상관없지만, 기존 이름에 C만 더 붙여서 CDlg로 클래스 이름을 지정해주는 것도 하나의 방법입니다.
(Dlg1 can be used, but it is also a way to specify the class name as CDlg by adding C to the existing name.)

 

예제에서는 편의상 Dlg1으로 하였습니다.(In this example, we have used Dlg1 for convenience.)

 


3. 메뉴에 다이얼로그 커맨드 기능 추가하기(Adding dialog command functions to the menu)

 

메뉴에 다이얼로그 커맨드 기능을 추가하겠습니다.(We will add a dialog command function to the menu.)

 

 

"예"라는 항목에 ID에 "ID_TOOLS_EX"로 지정하였습니다.(You have assigned "ID_TOOLS_EX" to the ID of "Yes".)

 

 

오른쪽 버튼을 클릭 후 "이벤트 처리기 추가(A)..."를 클릭합니다.
(Right click and click "Add Event Handler ...")

 

 

그림처럼 설정이 되어있을 것입니다. 확인을 클릭합니다. (It will be set as shown. Click OK.)

 


4. 코드 작성(Write the code)

 

코드 작성은 크게 어렵지 않게 진행할 수 있습니다.(Writing code can be very easy.)

 

 

그림에서는 CDlg.h로 되어있는데, 앞에 설명은 Dlg.h로 설명한 것처럼 보일 수 있습니다.

앞에서 지정한 헤더명으로 입력해주시면 됩니다.

Inteligence 기능으로 헤더를 찾아주기 때문에 적절히 잘 지정해주면 될 것 같습니다.

 

(In the figure, it is called CDlg.h, which may look like the one described as Dlg.h.

Enter the header name you specified earlier.

The Inteligence function finds the header, so I think it should be properly specified.)

 

 

 

반응형

+ Recent posts