Steps to Build Frame Window Recipe Application

Slides:



Advertisements
Similar presentations
1 After completing this lesson, you will be able to: Create a database. Create a table using the Table Wizard. Create and modify a table in Design view.
Advertisements

Step-by-Step: Add a Graphical Hyperlink USE the Special Events Final presentation that is still open from the previous exercise. 1.Go to slide 4, and click.
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
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
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.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Access Tutorial 10 Automating Tasks with Macros
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
© 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-
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
Creating a Web Site to Gather Data and Conduct Research.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
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.
OBJECTIVE  After completing this Lab, students will upgrade their knowledge in the field of VC++.  Students will also get the clear view about the concepts.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
FrontPage Tutorial Part 2 Creating a Course Web Site.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
1. Chapter 20 Managing Shared Documents 3 Working Together on Documents Word provides features to help workgroup members collaborate on documents. Insert.
FOCUS II Demonstration Simply click the mouse to advance through the presentation. Or; Tap the right arrow key on the keyboard to advance through the slides.
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 6: FILE I/O and Serialize CFile class. FILE I/O Serialization and the CArchive Class.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Copyright © 2007 by Pearson Education 1 UNIT 6A COMBINATIONAL CIRCUIT DESIGN WITH VHDL by Gregory L. Moss Click hyperlink below to select: Tutorial for.
© Ms. Masihi.  A Web page contains text and images that convey specific information to viewers.  To create a new web page, open Dreamweaver and select.
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Multiple Forms and Menus
Excel Tutorial 8 Developing an Excel Application
Introduction to Windows Programming
Practical Office 2007 Chapter 10
Creating LOVs and Editors
Customizing the Toolbar
Using a template to create a document
European Computer Driving Licence
Looking at our “Getting Started” application
Building a User Interface with Forms
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
1. Introduction to Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
Working with Dialogs and Controls
MFC Dialog Application
An Introduction to Computers and Visual Basic
2. Double-click on file to open in Excel
Chapter 2 – Introduction to the Visual Studio .NET IDE
Working with Headers and Footers
CIS16 Application Development Programming with Visual Basic
1. Open Visual Studio 2008.
An Introduction to Computers and Visual Basic
European Computer Driving Licence
Shelly Cashman: Microsoft Windows 10
Creating Additional Input Items
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Steps to Build Frame Window Recipe Application
Tutorial 10 Automating Tasks with Macros
Microsoft Excel 2007 – Level 2
Presentation transcript:

Steps to Build Frame Window Recipe Application Jim Fawcett CSE 691/791 – Software Modeling & Analysis Fall 2001

Running Application

Goals of Project Display a static text message in the center of the client area. Show current mouse coordinates in a text message above the static message. Show current mouse coordinates in static control above the message from item 2., demonstrates how that can be done. Toggle the message from item 2. on and off, using a menu selection labeled “toggle”

Construction Steps – App Wizard Run Application Wizard Select MFC AppWizard (exe) Select single document with no document/view support (uncheck that checkbox), in step 1 of the wizard. This may not work unless you have Visual Studio service pack 5 or later. You can take the defaults in steps 2-6 of the wizard. Click finish Result is an executable blank frame window application

Start Application Wizard and Select MFC AppWizard (exe)

Select SDI based Application

Construction Steps – Resource Editor Click on Resource View in the left-hand window, and click on FWRecipe resources/menu/IDR_MAINFRAME. That shows the menu bar. Click on the Edit item, and select each of its items in turn and hit the delete key to remove them. Type in the word Toggle in the box below the Edit tag. Right click on the Toggle word and select properties. Change the caption from Toggle to &Toggle. That gives you an alt-T accelerator key. Change the ID entry to ID_Toggle. Compile the program to see an empty frame window with the normal system menu, except that when you click on edit you will see the single Toggle item grayed out. It is grayed out because we have not defined a message handler for that yet.

Deleting Menu Items

Adding New Menu Item

Construction Steps – Add Message Handlers Kill the running window app and double click on the Toggle menu item. That will bring up the class wizard so you can define a message handler for that menu item. Click on the Message Maps tab and select ID_Toggle in the left pane and select COMMAND in the right pane. Click Add Function button to get a small dialog with a suggested OnToggle message handler name. Keep that name and click OK, and add the code from the example to the function body.

Use Class Wizard to Add Menu Handler

Adding OnToggle Handler

Add Members in MainFrame to Save and Use Toggle State In the left hand pane, click on Class View – this is a very important view, excellent for navigating around your code and initiating class wizard activities. Right click on CmainFrame class and select Add Member Variable. Enter the type BOOL and name m_bToggle in the resulting dialog. MAKE SURE YOU SELECT Private – Public is the default selection. Click OK. This creates a private member variable named m_bToggle in the CmainFrame class to hold the state of the menu toggle. Right click on CmainFrame in the Class View again, and select Add Member Function. In the resulting dialog enter the return type BOOL and the name getToggle(). This time leave the selection as public. This will create an accessor function for your view to get the state of the toggle. Add the code “return m-bToggle;” to the function body.

Use Class View to Access Class Wizard

Add Member Variable

Use Wizard to Add Member Function

Add Accessor Member Function

Add Member Code

Steps to Support View Double click on the CChildView class in the class view to navigate to that class decarlaration. View the inline function OnPaint() that the wizard has defined for you, with only the statement “CPaintDC dc(this);” This is one of several places that we will add a lot of code. Right click on the CChildView class and select Add Windows Message Handler. You will get a dialog that may show “Not a Window” in the bottom right combo box. Change that selection to Child Window and select WM_LBUTTONDOWN, and Add handler. Repeat for WM_MOUSEMOVE. Note that the class wizard has already provided the message hanler for the WM_PAINT message (the OnPaint function we looked at in step 13. Add code from the class example to OnMouseMove and OnLButtonDown message handler functions, skipping the last four lines in OnMouseMove. Add member variables m_DisplayX, m_DisplayY, m_MouseX, m_MouseY, and m_TriangleX and m_TriangleY as private data members of the CChildView class. Do that using the wizard like we did before, or add them manually by typing into the class declaration. These code additions will draw the static text in the center of the diagram, draw a triangle at the cursor when the left button is clicked, and show the mouse coordiates in a text messge. Compile and show that this works.

OnPaint Function

Add Code to Child View

Adding Message Handlers

Change Filter to Show Messages

Select Messages to Handle

Add Code to Handle Messages

Add Static Control to Client Area Now, we want to add the static control to also show mouse coordinates. Go to the FileView and double click on resource.h to see the contents of that file in the edit window. Add #define IDC_STATIC1 and pick a number to enter on the right which is one more that the highest number shown in the top group. Add 1 to the value of _APS_NEXT_COMMAND_VALUE. Add the member variable m_pCStatic as a private data member of the CChildView class typed as Cstatic*. Go to the ChildView::OnCreate function and add the statements: m_pStatic = new CStatic(); CRect rect(CPoint(100,70),CSize(90,22)); m_pCStatic->Create(“”,WS_CHILD|WS_VISIBLE|WS_BORDER, rect, this, IDC_STATIC1); This creates the static control. Add the bottom four lines of code from the CChildView::OnMouseMove function in my example.

Declare Reference to Static Control

Add Pointer to Static Control as Member

Add Code to Handle Messages

Initialize Members in Main and Child Classes Finally, we need to give initial values to the member variables we added to CMainFrame and CChildView. Add the intializer : m_bToggle(TRUE) to the CMainFrame::CMainFrame() constructor. Add the intializers to the CChildView::CChildView() : m_DisplayX(100), m_DisplayY(100), m_MouseX(0), m_MouseY(0), m_TriangleX(-1), m_TriangleY(-1), m_pCStatic(NULL) and add to the CChildView::~CChildView() destructor: delete m_pCStatic; Compile and see the running program in all its glory.

Initialize MainFrame Member

Initialize Child View Members

Running Application

Structure of FWRecipe Program

Closing Notes Test application by compiling and running each time you add a new Windows Message Handler. Make sure you #include “stdafx” in the cpp file for each server module you add – we haven’t used any server modules in this example, but you will want to for any relatively complex application. Test each server module as a stand-alone module, using its test stub, before you call it from the interface code. Your server modules are usually called by the interface message handlers: They affect transformations on the application’s data in response to user inputs.