Working with Dialogs and Controls

Slides:



Advertisements
Similar presentations
Interaction Design: Visio
Advertisements

PRIMARY, SECONDARY & QUANTITATIVE RESEARCH TASK HYPERLINK APPLICATION PROCEDURE 1.
Automating Tasks With Macros
Introduction to Microsoft Windows MFC Programming: the Application/Window Approach Lecture 4.
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.
Using Microsoft Outlook: Basics. Objectives Guided Tour of Outlook –Identification –Views Basics –Contacts –Folders –Web Access Q&A.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
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.
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Interaction Design Interaction Design - Joan Cahill - Visio Interaction Design: Visio.
Teacher’s Assessment Assistant Worksheet Builder Starting the Program
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 Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
Chapter 7 Controls.
BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
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.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
1 11 Exploring Microsoft Office Access 2007 Chapter 6 Data Protection.
XP Tutorial 8 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Object Linking and Embedding Tutorial 8.
Chapter 8 Dialog Boxes and Property Sheet
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.
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…
Creating ActiveX Controls at runtime If you need to create an ActiveX Control at runtime without a resource template entry, follow the programming steps.
DB Implementation: MS Access Forms. MS Access Forms: Purpose Data entry, editing, & viewing data in Tables Forms are user-friendlier to end-users than.
Dialog Boxes and Property Sheets
Dive Into® Visual Basic 2010 Express
Excel Tutorial 8 Developing an Excel Application
Introduction to Windows Programming
Document/View Architecture
Message Handling in MFC
Visual Basic 2010 How to Program
Forms Concepts Triggers Fired when Internal/External events occur
Working in the Forms Developer Environment
Steps to Build Frame Window Recipe Application
Topics Graphical User Interfaces Using the tkinter Module
Creating LOVs and Editors
Forms and Reports 09.
Chapter Topics 15.1 Graphical User Interfaces
About SharePoint Server 2007 My Sites
Building a User Interface with Forms
Program and Graphical User Interface Design
1. Introduction to Visual Basic
Dialog Boxes and Property Sheets
Using Procedures and Exception Handling
DB Implementation: MS Access Forms
Program and Graphical User Interface Design
Chapter 7 Advanced Form Techniques
Microsoft Windows 2000 Professional
Multi-form applications and dialogs
MODULE 7 Microsoft Access 2010
Microsoft Office Ribbon
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.
ITEC 1001 Test 5 Review.
DB Implementation: MS Access Forms
Object-Oriented Programming: Inheritance and Polymorphism
Web Development Using ASP .NET
Chapter 15: GUI Applications & Event-Driven Programming
Microsoft Office Ribbon
Creating Additional Input Items
Using Microsoft Outlook: Outlook Support Number
Presentation transcript:

Working with Dialogs and Controls CITA 342 Section 11 Working with Dialogs and Controls

Modal Dialog Boxes Modal dialog boxes require users to close or cancel the dialog box before they can continue working with an application. Once a modal message box appears on your screen, you cannot access any other window in an application until you close the message box.

Modeless Dialog Boxes In comparison to a modal dialog box, modeless dialog boxes do not need to be closed before you return to another window in the application. Modeless dialog boxes function more like frame windows and other types of primary application windows. Modeless dialog boxes require quite a bit more work than modal dialog boxes.

Dialog Boxes Much of the behind-the-scenes work, such as closing and destroying the dialog window, is handled automatically with modal dialog boxes. With modeless dialog boxes, however, especially in dialog-based applications, you need to override several inherited member functions. Overriding the inherited member functions allows you to correctly close and destroy the dialog window.

Displaying Modal Dialog Boxes You display a modal dialog box from an application’s InitInstance() function, the same way you display a frame window. You instantiate an object of the dialog class and use the inherited DoModal() function to display the modal dialog box. By default, if a user clicks a button containing a resource ID of IDOK or IDCANCEL, the dialog box closes.

Displaying Modal Dialog Boxes The IDOK resource ID represents the OK button, and the IDCANCEL resource ID represents the Cancel button. The DoModal() function returns an integer value representing the resource ID that caused the dialog box to close. You use these resource IDs in an if statement to take the appropriate action, depending on whether the user pressed the OK button or the Cancel button.

Displaying Modeless Dialog Boxes Construct using the resource editor in the same way as a modal dialog. Launch it by calling CDialog::Create(). instead of CDialog::DoModal(). Dismiss it by calling CWnd::DestroyWindow(). instead of CDialog::EndDialog(). you must NEVER call EndDialog() for a modeless dialog. you MUST override OnCancel() in order to prevent it from calling EndDialog().

Working with Controls Dialog boxes typically contain groups of controls through which a user interacts with an application. Controls are user interface items such check boxes, command buttons, text boxes, and other objects. You add controls to a dialog box by using the Controls toolbar in the Dialog Editor.

Dialog Box All dialog boxes—whether standard or custom—are created using two components: a dialog resource and a dialog class derived from the CDialog class. The dialog resource represents the visual aspect of the dialog box, and the dialog class provides programmatic access to the dialog box.

Dialog Data Exchange/Validation MFC provides a special mechanism called dialog data exchange, or DDX, to handle the exchange of values between controls and variables. A related mechanism called dialog data validation, or DDV, assists in the validation of data as it is exchanged between controls and variables. Before you can use DDX or DDV, you must first override the DoDataExchange() function in the class derived from CDialog that is associated with your dialog resource ID.

MFC Controls Controls are the user interface objects used to create interfaces for Windows applications. Most Windows applications are nothing but a collection of controls arranged in a way that appropriately implements the functionality of the program. There are only six basic controls - CStatic, CButton, CListBox, CComboBox, CEdit, and CScrollBar - along with some minor variations (Windows added a collection of about 15 enhanced controls as well).

Control Examples

Control Classes Six basic MFC Control Classes:

Common Controls See https://msdn.microsoft.com/en-us/library/47xcww9x(v=vs.140).aspx

Dialog Editor Picture (bmp, mtf, icn, …) Static Text, Edit Box Group Box, Button Check Box, Radio Button Combo Box, List Box Scroll Bars Spin Control, Progress Slider, Hot-Key List, Tree Tab Control, Animation Rich Edit, Custom Controls are dragged onto the control with the mouse and some are also sized using the mouse - the resource file is created by the resource editor. Right click on a selected control to get a property sheet which can be used to set control styles.

Controls The Resource Editor makes it easy to add controls to dialog boxes. The controls are automatically created when the dialog is created. The Class Wizard makes it easy to link these controls to dialog class member functions or member variables.

Controls Controls are actually Windows Controls are Child Windows They have their own window procedures (provided by Windows). In MFC, they inherit all the CWnd functionality. Controls are Child Windows clipped to parent, move with parent, destroyed with parent. when using VC++ Resource Editor - parent is usually a dialog class derived from CDialog. send WM_COMMAND notifications to parent.

CDialog Usually encapsulate your dialog box by a class derived from CDialog. To add member variables corresponding to the controls. Exception: simple dialogs with no data (e.g., About box).

CDialog Primary overridable (virtual) functions: OnInitDialog(): Override to initialize the dialog window or the controls. Call the base class version as well. OnOK(): Called when a button with the IDOK identifier is pressed. Do NOT need a message map entry for this. To extract & validate data from controls (unless DDX/DDV). Finish a modal dialog by calling base version or EndDialog() int passed to EndDialog() is returned to caller of DoModal().

CDialog Overridable (virtual) functions: OnCancel(): Called when a button with the IDCANCEL identifier is pressed, or when the ESC key or close button is pressed. Do NOT need a message map entry for this. Rarely overridden (except for modeless dialogs).

CDialog::DoModal() DoModal() shows the dialog window, and returns the value that the CDialog passes to EndDialog(). The default OnOK() calls EndDialog(IDOK.) The default OnCancel() calls EndDialog(IDCANCEL). You can call EndDialog() with other IDs if you wish.

DDX / DDV Basics Can use Class Wizard to create dialog data members and associate them with controls. Controls are “magically” initiated from the data members. OK “magically” sets the data members from the controls.

DDX / DDV Basics DoDataExchange() calls the appropriate DDX_ and DDV_ functions for each control. Pressing CANCEL (instead of OK) will simply not copy the data members to the View class variables.

DDX / DDV Basics You can force an exchange between the dialog member variables and the controls from anywhere in your dialog class by calling: UpdateData(TRUE): transfers from controls to variables. UpdateData(FALSE): transfers from variables to controls.

DDV Note that DDV data validation still doesn't happen until UpdateData() is called. most users would rather be told about an out-of-range selection BEFORE they hit the OK button. To do immediate range checking on most controls, you'll have to implement control message handlers.

Dialog as Main Window Popular approach for simple Apps: primary I/O through controls, rather than graphics or text. document / view organization not justified. MSVC AppWizard gives you this option, but it will create a modal dialog as the main window.

Common Dialogs Standard implementations of commonly used dialog functions: