1 / 25

LẬP TRÌNH WINDOWS

LẬP TRÌNH WINDOWS. Dialog Box Common Dialog Property Sheet. Giới thiệu. - DialogBox Common dialog Property Sheet. Giới thiệu - Common dialog. Save file dialog. Giới thiệu - Common dialog. Color dialog. Giới thiệu - Common dialog. Fonts dialog. Giới thiệu - Property Sheet.

neron
Download Presentation

LẬP TRÌNH WINDOWS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LẬP TRÌNH WINDOWS Dialog Box Common Dialog Property Sheet

  2. Giớithiệu • - DialogBox • Common dialog • Property Sheet

  3. Giớithiệu- Common dialog Save file dialog

  4. Giớithiệu- Common dialog Color dialog

  5. Giớithiệu- Common dialog Fonts dialog

  6. Giớithiệu- Property Sheet

  7. Tạoứngdụng Dialog Based bằng AppWizard • Chọn menu File → New • Chọn Tab Projects • Chọnloại project “MFC AppWizard (exe)” • Đặttên project trong ô “Project name” • Step 1: Chọnloạiứngdụng “Dialog based” • Nhấn “Finish” để kết thúc • Step 2: Chỉchọn Option “3D controls”

  8. Dialog based - Cácthànhphầncủaứngdụng • abc.h: header file của file abc.cpp, chứa khai báo CabcApp đểquảnlýtoànbộứngdụng. LớpCabcAppkếthừatừlớpCWinAppcủa MFC • abcDlg.h: header file của file abcDlg.cpp, chứakhaibáoCabcDlg để quản lý cửa sổ Dialog giao diện của ứng dụng. • LớpCabcDlgkếthừatừlớpCDialogcủa MFC • Resource.h: header file, chửacáchằng ID củacác resource được định nghĩa trong file abc.rc • abc.cpp: cài đặt các hàm thành phần của lớp CabcApp • abc.rc: môtảcác resource củaứngdụng • abcDlg.cpp: cài đặt các hàm thành phần của lớp

  9. Tạovàxửlý dialog 􀂙 Thêmmới Dialog resource 􀂙 Thiếtlậpthuộctính dialog 􀂙 KhaibáolớpCDialog 􀂙 Thêmcác control vào dialog 􀂙 Hiểnthị dialog 􀂙 Xửlý dialog

  10. Thêmmới dialog resource

  11. Khaibáolớpquảnlý dialog Bấmdoubleclickvào dialog mớihoặcbấm Ctrl + W (vào Class WiZard) => khaibáolớptươngứng

  12. Khaibáolớpquảnlý dialog - Đặttênlớpquảnlý dialog

  13. Tạovàxửcác control trong dialog

  14. Lậptrìnhvới Property Sheet

  15. Property Sheet - Thêmmới Property Page Thêm mới Dialog tương ứng với mỗi Page trongResouceView Khai báo lớp xử lý tương ứng với mỗi page, kếthừatừlớpCPropertyPage Add các page vào Property Sheet

  16. Lậptrìnhvới Property Sheet

  17. Tạolớp Property Sheet

  18. Thêmmới Property Page • Thêm mới Dialog tương ứng với mỗi Page trong • ResouceView • Khai báo lớp xử lý tương ứng với mỗi page, kếthừatừlớp • CPropertyPage • Add các page vào Property Sheet

  19. Page 1 – Page 2 IDD_PAGE2 IDD_PAGE1

  20. Thêmmới Property Page - Page 1 + Page 2 IDD_PAGE2 IDD_PAGE1

  21. Thêmmới Property Page #include "MyPage1.h" #include "MyPage2.h" class CMyPropertySheet : public CPropertySheet { ….. protected: CMyPage1 m_MyPage1; CMyPage2 m_MyPage2; …. };

  22. Add Property page vàoPropertySheet CMyPropertySheet::CMyPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { AddPage(&m_MyPage1); AddPage(&m_MyPage2); } CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage) { AddPage(&m_MyPage1); AddPage(&m_MyPage2); }

  23. Hiệnthị Property Sheet void CMyMFCDlg::OnShow() { CMyPropertySheetdlg("Sheet Page Demo", this, 0); dlg.DoModal(); } Hiểnthị “page 1” của PropertySheet

  24. Common Dialog

  25. Common dialog – Open File void CMyMFCDlg::OnButton2() { CFileDialogfDlg(1,NULL,NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST , "C Header Files (*.h)|*.h| C++ Source Files (*.cpp)|*.cpp||"); if ( fDlg.DoModal() == IDOK) { CString s= fDlg.GetPathName(); } }

More Related