VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs In CExO7aDialog h #define WM goodbye WM user+5 In ICEx07aDialog cpp void CEXO7aDialog: OnCancel0 / not really a message handler( if (m pView !=NULL)(//modeless case m pView->PostMessage(WM GOODBYE, IDCANCED) else(CDialog: On Cancel0; //modal) void CEX07aDialog: OnoKo / not really a message handler( if (m pView ! =NULL)(//modeless case UpdateData(TRUE) m pView->PostMessage(WM GOODBYE, IDOK) else(CDialog: OnOKo; //modal case
VC++ Programming @ UESTC 6 ⚫ In CEx07aDialog.h #define WM_GOODBYE WM_USER+5 ⚫ In ICEx07aDialog.cpp void CEx07aDialog::OnCancel() // not really a message handler{ if (m_pView != NULL) {// modeless case m_pView->PostMessage(WM_GOODBYE, IDCANCEL);} else {CDialog::OnCancel(); // modal} } void CEx07aDialog::OnOK() // not really a message handler{ if (m_pView != NULL) {// modeless case UpdateData(TRUE); m_pView->PostMessage(WM_GOODBYE, IDOK);} else {CDialog::OnOK(); // modal case} } Chapter 7 The Modeless Dialog and Windows Common Dialogs
VC++ Programming@UESTC Chapter 7 The modeless dialog and Windows Common Dialogs The m p view points to the view object of this application which really contains the user-defined message hanlder ● In cex07 a view . h afx msg LRESULT On Goodbye( WPARaM wParam, LPARAM IParam) e In CEx07a Viewcpp LRESULT CEXO7a View:: OnGoodbye(WPARAM wParam, LPARAM IParam)i message received in response to modeless dialog OK and Cancel buttons m pDIg->Destroy Window return OL; BEGIN MESSAGE MAP(CEXO7a view, C View) ON MESSAGE(WM GOODBYE, OnGoodbye
VC++ Programming @ UESTC 7 ⚫ The m_pView points to the view object of this application , which really contains the user-defined message hanlder. ⚫ In CEx07aView.h afx_msg LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam); ⚫ In CEx07aView.cpp LRESULT CEx07aView::OnGoodbye(WPARAM wParam, LPARAM lParam){ // message received in response to modeless dialog OK and Cancel buttons m_pDlg->DestroyWindow(); return 0L;} BEGIN_MESSAGE_MAP(CEx07aView, CView) ON_MESSAGE(WM_GOODBYE, OnGoodbye) Chapter 7 The Modeless Dialog and Windows Common Dialogs