모달과 모달리스(Modal and Modaless)
모달과 모달리스(Modal and Modaless)
To create a modal dialog box, call either of the two public constructors declared in CDialog. Next, call the dialog object's DoModal member function to display the dialog box and manage interaction with it until the user chooses OK or Cancel. This management by DoModal is what makes the dialog box modal. For modal dialog
boxes, DoModal loads the dialog resource.
모달 대화 상자를 만들려면 CDialog에 선언된 두 개의 공용 생성자 중 하나를 호출하십시오. 그런 다음 대화 상자 개체의 DoModal 멤버 함수를 호출하여 사용자가 확인 또는 취소를 선택할 때까지 대화 상자를 표시하고 대화 상자와의 상호 작용을 관리합니다. DoModal에 의한 이러한 관리는 대화 상자를 모달로 만드는 것입니다. 모달 대화 상자의 경우 상자에서 DoModal은 대화 상자 리소스를 로드합니다.
https://docs.microsoft.com/en-us/cpp/mfc/creating-modal-dialog-boxes?view=msvc-170
For a modeless dialog box, you must provide your own public constructor in your dialog class. To create a modeless dialog box, call your public constructor and then call the dialog object's Create member function to load the dialog resource. You can call Create either during or after the constructor call. If the dialog resource has the property WS_VISIBLE, the dialog box appears immediately. If not, you must call its ShowWindow member function.
모덜리스 대화 상자의 경우 대화 클래스에 고유한 공용 생성자를 제공해야 합니다. 모덜리스 대화 상자를 만들려면 공용 생성자를 호출한 다음 대화 개체의 Create 멤버 함수를 호출하여 대화 상자 리소스를 로드합니다. 생성자 호출 중이나 호출 후에 Create를 호출할 수 있습니다. 대화 상자 리소스에 WS_VISIBLE 속성이 있으면 대화 상자가 즉시 나타납니다. 그렇지 않은 경우 해당 ShowWindow 멤버 함수를 호출해야 합니다.
https://docs.microsoft.com/en-us/cpp/mfc/creating-modeless-dialog-boxes?view=msvc-170
간단히 설명하면 모달(Modal)은 뒤로 갈 수 없는, 모달리스(Modaless)는 뒤로 갈 수 있는 있는 것이다.
모달과 모달리스(Modal and Modaless)에 대한 예시
1. 새 Dlg 리소스 생성
2. 새 Dlg에 Class 생성
3. 새 Dlg에 함수 추가
4. 부모 Dlg에서 적절히 호출
void CMFCApplication10Dlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CNewDlg child; // 자손 클래스 CNewDlg 생성
child.DoModal(); // 창을 띄운다.
}
void CMFCApplication10Dlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CNewDlg child;
child.SetEditBox(_T("하이 Hello")); // 미리 자료를 만들어놓고
child.DoModal(); // 창을 띄운다.
AfxMessageBox(_T("창이 닫혔습니다."));
}