Search

'OnOK'에 해당되는 글 2건

  1. 2017.02.08 [MFC] Dialog 닫기 (OnOK/EndDialog)
  2. 2016.09.22 MFC Dialog Modal

[MFC] Dialog 닫기 (OnOK/EndDialog)

Programming/MFC 2017. 2. 8. 16:54 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[MFC] Dialog 닫기 (OnOK/EndDialog)


 
1. OnOK()
 
2. OnClose()
 
3. EndDialog()
 
4. DestoryWindow()


CDialog::OnOK

Override this method to perform actions when the OK button is activated. If the dialog box includes automatic data validation and exchange, the default implementation of this method validates the dialog box data and updates the appropriate variables in your application.

If you implement the OK button in a modeless dialog box, you must override the OnOK method and call DestroyWindow inside it. Do not call the base-class method, because it calls EndDialog which makes the dialog box invisible but does not destroy it.

CDialog::EndDialog

Call this member function to terminate a modal dialog box.



virtual void CDialog::OnOk();
호출 : 사용자가 OK버튼을 누르면 호출된다. (id값이 IDOK인 버튼)
        즉, OnOk()함수는 OK버튼클릭 메시지 핸들러라고 할 수 있다.
사용 : 컨트롤 값을 읽거나 값의 타당성을 검사한 후 Dialog 닫기





다이얼로그를 닫을때 OnOK 로 닫는것 [확인(OK)] 버튼을 눌러서 닫는 것



EndDialog 는 다이얼로그를 강제로 중지시킨다.








MFC Dialog Modal

Programming/MFC 2016. 9. 22. 16:48 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

부모 Dialog 에서





자식 Dialog를 Domodal로 부른 뒤


  void CMyDialog::OnMenuShowSimpleModal()
{
   CSimpleDlg myDlg;
   INT_PTR nRet = myDlg.DoModal();

   if (nRet == IDOK || nRet == 5)
      AfxMessageBox(_T("Dialog closed successfully"));
}



자식 Dialog가 종료 될때




  void CSimpleDlg::OnRButtonUp(UINT nFlags, CPoint point)
{
   UNREFERENCED_PARAMETER(nFlags);
   // Do something

   int nRet = point.x; // Just any value would do!
   EndDialog(nRet); // This value is returned by DoModal!

   // Do something

   return; // Dialog closed and DoModal returns only here!
}