当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

VC++程序设计_AnlexVC++5(英文)

资源类别:文库,文档格式:PPT,文档页数:20,文件大小:85KB,团购合买
点击下载完整版文档(PPT)

VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs What is a modeless dialog? o What's the difference between modal and modeless dialogs? What's the relationship between the dialog and the view window? o Why do we need to use user-defined message in modeless dialog o what are the common dialogs and how to use them?

VC++ Programming @ UESTC 1 Chapter 7 The Modeless Dialog and Windows Common Dialogs ⚫ What is a modeless dialog? ⚫ What’s the difference between modal and modeless dialogs? ⚫ What’s the relationship between the dialog and the view window? ⚫ Why do we need to use user-defined message in modeless dialog? ⚫ What are the common dialogs and how to use them?

VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs e Modeless dialog allows user to work elsewhere in the application while the dialog is active Modal and modeless dialogs are derived from CDialog e Modal dialog can be constructed on the stack and so it is easy to be cleaned up Modeless dialog is more complicated

VC++ Programming @ UESTC 2 ⚫ Modeless dialog allows user to work elsewhere in the application while the dialog is active. ⚫ Modal and modeless dialogs are derived from CDialog. ⚫ Modal dialog can be constructed on the stack and so it is easy to be cleaned up. ⚫ Modeless dialog is more complicated. Chapter 7 The Modeless Dialog and Windows Common Dialogs

VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs Difference between creating a modal dialog and a modele dialog Modal Modeless Constructor used Constructor with Defaul resource ID constructor(no param param) Function used to DoModal Create with create window resource ID param 3

VC++ Programming @ UESTC 3 Difference between creating a modal dialog and a modeless dialog Modal Modeless Constructor used Constructor with resource ID param Default constructor (no param) Function used to create window DoModal Create with resource ID param Chapter 7 The Modeless Dialog and Windows Common Dialogs

VC++ Programming@UESTC Chapter 7 The modeless dialog and Windows Common Dialogs Created takes the resource ID as parameter and returns immediately with the dialog window still on the e screen o Programmer must determine the all actions for the modeless dialog such as creation, destroy and processing of user-entered data o C++ compiler distinguish modal and modeless dialog by looking at the Cexo7aDialog(C view*)or CEX07aDialog(C Wnd=)

VC++ Programming @ UESTC 4 ⚫ Create() takes the resource ID as parameter and returns immediately with the dialog window still on the screen. ⚫ Programmer must determine the all actions for the modeless dialog such as creation, destroy and processing of user-entered data. ⚫ C++ compiler distinguish modal and modeless dialog by looking at the CEx07aDialog(CView*) or CEx07aDialog(CWnd*) Chapter 7 The Modeless Dialog and Windows Common Dialogs

VC++ Programming@UESTC Chapter 7 The modeless dialog and Windows Common Dialogs o The view needs to know when to destroy the modeles dialog window e Usually a user-defined message is sent to the view after the user click the ok button on the modeless dialog Then the view destroy the dialog window but the dialog c++ class may still be there ● User-defined message #define WM GOodBYE Wm user+5

VC++ Programming @ UESTC 5 ⚫ The view needs to know when to destroy the modeless dialog window. ⚫ Usually a user-defined message is sent to the view after the user click the OK button on the modeless dialog. ⚫ Then the view destroy the dialog window but the dialog c++ class may still be there. ⚫ User-defined message #define WM_GOODBYE WM_USER+5 Chapter 7 The Modeless Dialog and Windows Common Dialogs

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

VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs Let think it over again The used-defined message inside dialog class and sends out the message to the view o The view handle the message do necessary jobs and finally destroy the modeless dialog window The view and modeless dialog have a pointer pointing to each other Inside view, create the modeless dialog window if(m pDlg->Get Safe Hwnd==0)i m pDIg->Created; //displays the dialog window j o Inside view destructor delete m pDIg

VC++ Programming @ UESTC 8 ⚫ Let think it over again. ⚫ The used-defined message inside dialog class and sends out the message to the view. ⚫ The view handle the message , do necessary jobs, and finally destroy the modeless dialog window. ⚫ The view and modeless dialog have a pointer pointing to each other. ⚫ Inside view, create the modeless dialog window if (m_pDlg->GetSafeHwnd() == 0) { m_pDlg->Create(); // displays the dialog window} ⚫ Inside view destructor delete m_pDlg; Chapter 7 The Modeless Dialog and Windows Common Dialogs

VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs Message Maps Member Variables Automation ActiveX Events Class Info I Project: Class name Add Class ex07a CE×07 dIalog Add Variable C: \\ex07 a\Ex07aDialog h, C: \\ex07a\Ex07aDialog cpp Control IDs Type Member Delete variable IDC EDIT1 IDCANCEL Update Columns IDOK Bind All Description CString with length validation Maximum Characters K Cancel

VC++ Programming @ UESTC 9 Chapter 7 The Modeless Dialog and Windows Common Dialogs

VC++ Programming UESTC Chapter 7 The modeless dialog and Windows Common Dialogs o Windows Common Dialogs They gather user information but do nothing with it O CoMCtL32. DLL contains the windows common control like treeview o COMDLG 32 DLL contains the various common dialogs CColor Dialog CFileDialog CPrint Dialog 10

VC++ Programming @ UESTC 10 ⚫ Windows Common Dialogs They gather user information but do nothing with it. ⚫ COMCTL32.DLL contains the windows common control like treeview; ⚫ COMDLG32.DLL contains the various common dialogs. CColorDialog CFileDialog …… CPrintDialog Chapter 7 The Modeless Dialog and Windows Common Dialogs

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共20页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有