Chapter 7 Controls.

Slides:



Advertisements
Similar presentations
Facilitator: Mrs. Nkeiruka Ojei
Advertisements

(MICROSOFT EXCEL). Is a spreadsheet application designed to take advantage of the windows graphical interface MICROSOFT EXCEL.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Chapter 2 Creating a Research Paper with Citations and References
1 Introduction to Word Chapter 2 Lecture Outline.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 3 1 Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional- Looking.
Introduction to MFC. Motivation Abstract the Windows API Provides additional GUI options Insert Open Inventor into existing MFC application Document /
Introduction to Computing Dr. Nadeem A Khan. Lecture 11.
Chapter 5 Using Business Information Sets
Tran Anh Tuan A.  Help to modify a control’s behavior by deriving classes of your own from the MFC control classes  Help to build reusable, self-contained.
Printing and Page Formatting ITSW 1401, Intro to Word Processing Instructor: Glenda H. Easter.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Microsoft Excel 2000 Adding Visual Elements and Managing Files.
Inspire students to develop ideas & organize thinking
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Intro to MFC. Open VS and create new project 1)Open MS Visual Studio 2008 Professional (It must be the Professional Edition, the Express Edition will.
Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional-Looking Worksheet.
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
1 Lesson 7 Getting Started with Word Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
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.
Chapter 15: Spreadsheet and Worksheet Basics © 2010, 2006 South-Western, Cengage Learning.
ME 142 Engineering Computation I Custom Dialog Boxes.
LINKS TO OBJECTIVES Multiple Worksheets Multiple Worksheets Move, Copy and Paste Cells Move, Copy and Paste Cells Split into Windows Freeze Panes Range.
BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
© 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 15 Advanced Tables.
Microsoft Outlook 2010 Chapter 3 Managing Contacts and Personal Contact Information with Outlook.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Lecture 7 Menu, controls, scroll bars. Menu Menu item sends WM_COMMAND message to the application window Menu is attached to window when the window is.
Chapter 7 Controls. Scroll bar control 3 Scroll bar control (1/3) Scroll bar codes (interfaces)
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
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.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
Microsoft Word 2010 Chapter 2 Creating a Research Paper with Citations and References.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Customizing Reports Adding a Date to a Report Reference Window Adding a Date to a Report Display the report in the design view Click the Text Box Tool.
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.
Word Processor Version.01 EME 4411 Week 5. The Scroll Bars.
1 After completing this lesson, you will be able to: Open a file. Navigate through a document. Scroll through a document. Insert text in a document. Select.
1 After completing this lesson, you will be able to: Create a form using AutoForm. Create a form using the Form Wizard. Add controls to a form. Modify.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Chapter 6: FILE I/O and Serialize CFile class. FILE I/O Serialization and the CArchive Class.
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
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
1 Word Processing Intermediate Using Microsoft Office 2000.
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Excel Tutorial 8 Developing an Excel Application
Message Handling in MFC
Chapter 1: An Introduction to Visual Basic 2015
Chapter Topics 15.1 Graphical User Interfaces
Introduction to Computing
Working with Dialogs and Controls
Introduction to the Visual C# 2005 Express Edition IDE
Variables and Arithmetic Operations
MODULE 7 Microsoft Access 2010
CIS16 Application Development Programming with Visual Basic
COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often.
Development The Foundation Window.
Chapter 5 Microsoft Excel Window
Chapter 15: GUI Applications & Event-Driven Programming
Presentation transcript:

Chapter 7 Controls

Introduction MFC Classic Controls Control Type WNDCLASS MFC Class Buttons "BUTTON" CButton List boxes "LISTBOX" CListBox Edit controls "EDIT" CEdit Combo boxes "COMBOBOX" CComboBox Scroll bars "SCROLLBAR" CScrollBar Static controls "STATIC" CStatic

How it works Controls and its parent window Notification Message When its states change Example) A button is being clicked Member Functions of the control Change or get the state of the control. Example) Change a button to be inactive Controls (Child Window) Parent Window ① Notification ② function call

Button Control Two ways of creating a control ① Create one by hand (coding) ② Create one using the dialog edit window

When clicking a button Windows sends Notification Message Message Handler for the notification Add message handler MACRO in massage map Implement the message handler function Controls (Child Window) Parent Window Notification

When changing state of CButton Call member functions of CButton Change(Set) the current state Acquire(Get) the current state Controls (Child Window) Parent Window function call

Member functions of CButton Change the state of the check box Check the state of the check box m_button.SetCheck(BST_CHECKED); m_button.SetCheck(BST_UNCHECKED); if ( m_button.GetCheck() == BST_CHECKED ) AfxMessageBox(_T(“Button is checked”));

Button Control Two ways of creating a control ① Create one by hand (coding) ② Create one using the dialog edit window

Dialog Edit Window Resource View -> Edit “Dialog” Control variables Creating and designing controls using toolbox Control variables Each control can be connected with a control variable. Call the member functions of the control variable to change/get the state of the control

Coding Practice Make a new project of Dialog Based Application Design the dialog using Dialog Edit Window and tool box

Adding Event Message Handler Use Properties window to add message handlers

Adding Event Message Handler Alternative way In dialog edit window, mouse right button click on a control  Add Event Handler

Creating control variables mouse right button click on a control  Add variables

Creating control variables Added things: // In Header file class CTestDlg::public CDiglog { ... CButton m_button; } // In Source file void CTestDlg::DoDataExchange(CDataExchange* pDX) CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(CExButtonView) DDX_Control(pDX, IDC_BUTTON1, m_button); //}}AFX_DATA_MAP

Coding Practice Creating the following program using Dialog based application template When pushing the button, show the information

More Controls

Edit Control (1/6) Edit Control Line option:

Edit Control (1/6) Properties

Edit Control (2/6) Edit Control Style Style Description ES_LEFT Left-aligns text in the control. ES_CENTER Centers text in the control. ES_RIGHT Right-aligns text in the control. ES_AUTOHSCROLL Permits the edit control to scroll horizontally without a horizontal scroll bar. To add a horizontal scroll bar, include the style WS_HSCROLL. ES_AUTOVSCROLL Permits the edit control to scroll vertically without a vertical scroll bar. To add a vertical scroll bar, include the style WS_VSCROLL. ES_MULTILINE Creates a multiline edit control. ES_LOWERCASE Displays all characters in lowercase. ES_UPPERCASE Displays all characters in uppercase. ES_PASSWORD Displays asterisks instead of typed characters. ES_READONLY Creates an edit control whose text can't be edited. ES_NOHIDESEL Prevents the edit control from hiding the selection when the control loses the input focus. ES_OEMCONVERT Performs an ANSI-to-OEM-to-ANSI conversion on all characters typed into the control so that the application won't get unexpected results if it performs an ANSI-to-OEM conversion of its own. Obsolete. ES_WANTRETURN Programs the Enter key to insert line breaks instead of invoking the default push button for multiline edit controls used in dialog boxes.

Edit Control (4/6) Edit Control Notification Messages Notification Sent When Message-Map Macro EN_UPDATE The control's text is about to change. ON_EN_UPDATE EN_CHANGE The control's text has changed. ON_EN_CHANGE EN_KILLFOCUS The edit control loses the input focus. ON_EN_KILLFOCUS EN_SETFOCUS The edit control receives the input focus. ON_EN_SETFOCUS EN_HSCROLL The edit control is scrolled horizontally using a scroll bar. ON_EN_HSCROLL EN_VSCROLL The edit control is scrolled vertically using a scroll bar. ON_EN_VSCROLL EN_MAXTEXT A character can't be entered because the edit control already contains the number of characters specified with CEdit::LimitText or CEdit::SetLimitText. ON_EN_MAXTEXT EN_ERRSPACE An operation fails because of insufficient memory. ON_EN_ERRSPACE

Coding Practice Adding Edit Control to the dialog application

How to change the state of CEdit Call member functions of CEdit Change(Set) the current state Acquire(Get) the current state To ways of connecting a control variable with the CEdit Control By hand (implement in the DoDataExchange function) An automatic way (add variables  control variable) Controls (Child Window) Parent Window function call

How to change the state of CEdit Two ways to connect a control variable with the CEdit Control By hand (implement in the DoDataExchange function) An automatic way (add variables  control variable)

Edit Control (5/6) Inserting and Retrieving Text Set maximum number of character Clear, Cut, Copy, Paste and Undo m_edit.SetWindowText(_T("초기값입니다.")); CString str; m_edit.GetWindowText(str); m_edit.SetLimitText(10); m_edit.Clear(); m_edit.Cut(); m_edit.Copy(); m_edit.Paste(); m_edit.Undo();

Edit Control (6/6) Select text for editing Before ① After ① After ② ① m_edit.SelSel(5, 7); ② m_edit.ReplaceSel("ABC");

Scroll bar control (1/3) Scroll bar codes (interfaces)

CScrollBar Class(2/3) Member functions Member functions meaning SetScrollRange() Set the min and max range of the scroll bar SetScrollPos() Set the thumb position GetScrollPos() Get the thumb position

Scroll bar notification(3/3) Messages: Add message MACRO in MessageMap Scroll Bars have no ID. Event Message Handler WM_HSCROLL/ WM_VSCROLL ON_WM_HSCROLL() or ON_WM_VSCROLL() void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

Scroll bar message handler (4/3) WM_HSCROLL/WM_VSCROLL 메시지 핸들러 nSBCode Scroll bar code (types of event) nPos Position of the thumb Only use when nSBCode is SB_THUMBPOSITION or SB_THUMBTRACK pScrollBar Pointer to the scroll bar void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

Coding Practice Add a edit control and scroll bar control Set the range of the scroll bar to (0, 100) Show the position value of the thumb in the edit control