Chapter 8 Dialog Boxes and Property Sheet. 2 Two kinds of dialog boxes Dialog boxes –Modal dialog When appear, it takes all ownership of input. It disables.

Slides:



Advertisements
Similar presentations
Facilitator: Mrs. Nkeiruka Ojei
Advertisements

MS-Word XP Lesson 7.
Benchmark Series Microsoft Access 2010 Level 1
© Paradigm Publishing, Inc Word 2010 Level 2 Unit 1Formatting and Customizing Documents Chapter 3Automating and Customizing Formatting.
Creating and Editing a Web Page Using Inline Styles
Objectives © Paradigm Publishing, Inc. 1 Objectives.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Using Macros and Visual Basic for Applications (VBA) with Excel
Chapter 3 Designing a Newsletter
Microsoft Expression Web-Illustrated Unit L: Using Code Tools.
Microsoft Word Review.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Introduction to MFC. Motivation Abstract the Windows API Provides additional GUI options Insert Open Inventor into existing MFC application Document /
Creating, Formatting, and Editing a Word Document with a Picture
Creating Tables in a Web Site Using an External Style Sheet HTML5 & CSS 7 th Edition.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Printing and Page Formatting ITSW 1401, Intro to Word Processing Instructor: Glenda H. Easter.
Operating Systems Day 6. Page Setup 1.Open notepad and type a document or file 2.Click on file menu 3.Click on page setup menu item 4.Select paper size,
1 After completing this lesson, you will be able to: Add text to slides. Adjust the position of text objects. Format text. Change text alignment and spacing.
PYP002 Intro.to Computer Science Microsoft Word1 Lab 07 Creating Documents with Efficiency and Consistency.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Chapter 3 Maintaining a Database
Power Point EDU 271 Microsoft PowerPoint is a powerful tool to create professional looking presentations and slide shows. PowerPoint allows you to construct.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Creating a Form on a Web Page
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Classic Controls Trần Anh Tuấn A. Week 1 How to create a MFC project in VS 6.0 How to create a MFC project in VS 6.0 Introduction to Classic Controls.
XP Practical OpenOffice.org Chapter 8 1 Creating a Presentation.
Chapter 7 Controls.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Microsoft Publisher 2010 Chapter 1 Creating a Flyer.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 7 – Creating and Using Templates in a Web.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
XP Tutorial 8 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Object Linking and Embedding Tutorial 8.
Chapter 3 Automating Your Work. It is frustrating when you have to type the same passage of text repeatedly. For example your name and address. Word includes.
Click the mouse to continue. Using styles A style is a saved collection of formatting, such as a font, font size, pattern, and alignment, that you can.
HTML Concepts and Techniques Fifth Edition Chapter 3 Creating Web Pages with Links, Images, and Formatted Text.
Chapter 7 Controls. 2 Introduction (1/4) Control –Special kind of window –Designed to convey information to the user or to acquire input –Reduce the tedium.
Chapter 8 Dialog Boxes and Property Sheet
Creating and Editing a Web Page
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Creating and Editing a Web Page Using Inline Styles
Prepared by the Academic Faculty Members of IT. Tables Creating Tables. Merging Cells. Splitting Cells. Sorting Tables. Performing Calculations.
Chapter 6: FILE I/O and Serialize CFile class. FILE I/O Serialization and the CArchive Class.
Chapter 28. Copyright 2003, Paradigm Publishing Inc. CHAPTER 28 BACKNEXTEND 28-2 LINKS TO OBJECTIVES Table Calculations Table Properties Fields in a Table.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Chapter 7 Controls. List box control 3 List Box Control(1/8) Listbox control: –Display lists of text strings called items –Optionally sort the items.
Creating Web Pages with Links, Images, and Embedded Style Sheets
Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines…
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Creating ActiveX Controls at runtime If you need to create an ActiveX Control at runtime without a resource template entry, follow the programming steps.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Dialog Boxes and Property Sheets
Excel Tutorial 8 Developing an Excel Application
Working with Dialogs and Controls
Dialog Boxes and Property Sheets
Java Code Review with CheckStyle
Microsoft Excel 2007 – Level 2
Presentation transcript:

Chapter 8 Dialog Boxes and Property Sheet

2 Two kinds of dialog boxes Dialog boxes –Modal dialog When appear, it takes all ownership of input. It disables the window until the dialog box is dismissed. –Modeless dialog It behaves more like a conventional window. It activates together with other windows.

3 How to create dialog box Design a dialog template by using dialog box edit tool in the resource view Edit resource file by your self. –Edit Resource script(*.RC) manually

4 A dialog box template Using a resource view to design a new dialog box

5 A dialog box template Add or delete controls –Using Toolbox menu

6 A dialog box template Align templates –Use dialog editor tool bar –Or use Format menu

7 A dialog box Template Tab order –Determine the order of the focus changing when tab key is pressed –Use [Format]->[Tab Order] menu

8 Two types of dialog boxes Dialog boxes –Modal dialog When appear, it takes all ownership of input. It disables the window until the dialog box is dismissed. –Modaless dialog It behaves more like a conventional window. It activates together with other windows.

9 Modal dialog box How to create and show it ① Design a dialog box template  Resource View ② Create a CDialog derived class using the template  Use [Project] [add class] menu ③ Call CDialog::DoModal() function to show the dialog box

10 Modal Dialog box MFC Class Heirarchy

11 Modal dialog box Main Virtual functions of CDialog class –WM_INITDIALOG message handler –When initializes the dialog box –Good place for initializing other controls –IDOK message handler (when pressing OK button) –Good place for updating variables before closing the dialog box, virtual BOOL CDialog::OnInitDialog ( ); virtual void CDialog::OnOK ( );

12 Modal dialog box Main Virtual functions of CDialog class –IDCANCEL message handler (when pressing cancel button) –Close the dialog box virtual void CDialog::OnCancel ( );

13 OnOK() and OnCancel() function Call EndDialog function to close the dialog box void CDialog::OnOK() { UpdateData(TRUE);// update the variables EndDialog(IDOK); } void CDialog::OnCancel() { EndDialog(IDCANCEL); }

14 DDX/DDV (1/8) How to connect your variables in the parent window with a dialog box: –Add the same variables and connect them to the controls Ex) create two variables and change them using a dialog box class CMyDialog : public CDialog {... CString m_str ; int m_color ;... }

15 DDX/DDV (2/8) What you have to: IDC_STR IDC_COLOR ①② Dialog box m_str m_color Dialog variables m_str m_color Parent variables IDC_STR IDC_COLOR ③ ④ Dialog box m_str m_color Dialog variables m_str m_color Parent variables When showing dialog box When pressing OK button

16 DDX/DDV (3/8) How to implement it: BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); SetDlgItemText(IDC_STR, m_str); SetDlgItemInt(IDC_COLOR, m_color); return TRUE; } void CMyDialog::OnOK() { GetDlgItemText(IDC_STR, m_str); m_color = GetDlgItemInt(IDC_COLOR); CDialog::OnOK(); }

17 DDX/DDV (4/8) An automatic way: –DDX(Dialog Data eXchange) IDC_STR IDC_COLOR ①② 대화상자 m_str m_color 대화상자 객체 m_str m_color 뷰 객체 IDC_STR IDC_COLOR ③ ④ 대화상자 m_str m_color 대화상자 객체 m_str m_color 뷰 객체 Automation?

18 DDX/DDV (5/8) OnInitDialog(), OnOK() implementation BOOL CDialog::OnInitDialog() {... UpdateData(FALSE);// Give the values to the controls... } void CDialog::OnOK() {... UpdateData(TRUE);// Retrieve the values // from the controls... }

19 DDX/DDV (6/8) What is CWnd::UpdateData() function? BOOL CWnd::UpdateData(BOOL bSaveAndValidate) {... CDataExchange dx(this, bSaveAndValidate); DoDataExchange(&dx);... }

20 DDX/DDV (7/8) Implementation of DDX –Connecting a variable with a control Use DDX_* MACRO void CMyDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDialog) DDX_Text(pDX, IDC_STR, m_str); DDX_Text(pDX, IDC_COLOR, m_color); //}}AFX_DATA_MAP }

21 DDX/DDV (8/8) DDV(Dialog Data Validation) –Automation of the validation of the data Check the range of the data Use DDV_* MACRO void CMyDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDialog) DDX_Text(pDX, IDC_STR, m_str); DDV_MaxChars(pDX, m_str, 10); DDX_Text(pDX, IDC_COLOR, m_color); DDV_MinMaxInt(pDX, m_color, 0, 255); //}}AFX_DATA_MAP }

Coding Practice Create a dialog box as shown below and show it when pressing mouse left button Type on the edit control and choose a text color value from the radio buttons

23 Two types of dialog boxes Dialog boxes –Modal dialog When appear, it takes all ownership of input. It disables the window until the dialog box is dismissed. –Modaless dialog It behaves more like a conventional window. It activates together with other windows.

24 Modaless Dialog Box Same thing: –Create a dialog template and add a CDialog-derived class. Different thing: –Do not use CDialog::DoModal() function –Use CDialog::Create() function for initialization Ex: CDialog::Create( Resource_ID, parent_wnd); –Use CDialog::ShowWindow() function for showing –Use CWnd::DestroyWindow() function to close

Modaless dialog box test Create a dialog box as shown below and show it as a modaless dialog box. Type on the edit control and choose a text color value from the radio buttons

Common Dialog Boxes

27 Common Dialog Box MFC Class Hierarchy

28 Common Dialog Dlasses ClassDialog Type(s) CFileDialogOpen and Save As dialog boxes CPrintDialogPrint and Print Setup dialog boxes CPageSetupDialogPage Setup dialog boxes CFindReplaceDialogFind and Replace dialog boxes CColorDialogColor dialog boxes CFontDialogFont dialog boxes

29 CColorDialog CColorDialog dlg; dlg.DoModal(); COLORREF color = dlg.GetColor(); CColorDialog dlg(RGB(255, 0, 0), CC_FULLOPEN); dlg.DoModal(); COLORREF color = dlg.GetColor();

30 CFileDialog CFileDialog dlg(TRUE); if(dlg.DoModal() == IDOK) MessageBox(dlg.GetPathName()); CFileDialog dlg(FALSE); if(dlg.DoModal() == IDOK) MessageBox(dlg.GetPathName());

31 CFontDialog CFontDialog dlg; if(dlg.DoModal() == IDOK){ CClientDC dc(this); // Get Color COLORREF color = dlg.GetColor(); dc.SetTextColor(color); // Get Font LOGFONT lf; dlg.GetCurrentFont(&lf); CFont font; font.CreateFontIndirect(&lf); dc.SelectObject(&font); // Show Text dc.TextOut(10, 10, CString(" 한글 & English")); }

32 CPageSetupDialog CPageSetupDialog dlg; dlg.DoModal();

33 CPrintDialog CPrintDialog dlg(TRUE); dlg.DoModal(); CPrintDialog dlg(FALSE); dlg.DoModal();