Steps to Build Proto 1 Dialogbased Application Jim
Steps to Build Proto 1 Dialog-based Application Jim Fawcett CSE 691/791 – Software Modeling & Analysis Fall 2001
Running Application
Construction Steps – App Wizard · · · · Run Application Wizard Select MFC App. Wizard (exe) Check Dialog based Deselect Active. X controls at step 2 Accept defaults at step 3 Change class name at step 4 if you wish Click finish Result is an executable blank dialog application
Start Application Wizard and Select MFC App. Wizard (exe)
Select Dialog based Application
Construction Steps – Resource Editor · · · · · Stretch dialog to fit desired size. Move buttons to locations appropriate for this interface. Add List. Box and Edit. Box from palette to form. They will be used for CRC titles and CRC text, respectively. Add second Edit. Box at top of form. This will be used to add a title for a new CRC item. Add labels for CRC title and CRC text, above List. Box and Edit. Box. Remove OK button, move cancel button next to top Edit. Box to trigger addition of new CRC. Right click on remaining button to bring up property box, change caption. Do the same for both static labels. Change button ID to ID_NEW.
Stretch Dialog to Fit
Add Controls, Set Properties
Construction Steps – Add Message Handlers · · · Add handler for adding new CRC when a new title is typed into the top Edit. Box, detected by hitting an enter key when focus is in Edit. Box, or when the New Title button is clicked. Add handler for editing CRC text when changes are made to the contents of the right-hand CRC Text Edit. Box. Add handler for selecting a CRC to view or modify from the CRC Title List. Box.
Proto 1 – Dialog based Application
Add or Modify Handler Code · · Build and test module CRCrep to manage CRC data and provide the dialog with a CRC management interface. You can do this in a new console based project in the same workspace. Modify CProto. Dlg: : On. Init. Dialog to load List. Box with CRC titles and load Edit. Box with text for first CRC. – Provide member function CProto. Dlg: : load. CRCs() to support this intialization. · · Add On. Change. Edit 1 with class wizard. Its purpose is to copy changed CRC text from the Edit. Box to the in-memory CRC representation. Add code to this function, as in Proto 1. Repeat these steps for remaining message handlers: – – On. Change. Edit 1 On. Dblclk. List 1 On. New On. Ok store edit changes in CRCrep select CRC to view add new CRC handle return in new Edit. Box Look at the prototype code to see what to enter.
Activate Class Wizard
Add Windows Message Handlers
Application Structure
Steps to Finish Project · · · Add XML based persistance to CRCProc, probably by adding a new module, called by CRCProc functions. Revise initialization code to open a CRC database file, containing XML representations for the CRC card set. Add functionality to delete a CRC card. One way to do that would be to add a delete button on the main dialog. Then, when it is clicked, pop up a secondary dialog that confirms the delete operation. – We will create the dialog resource and a class to wrap it in the next few slides. – You will need to add code in the appropriate handlers to make it functional.
Insert New Resource
Insert Dialog Resource
Resulting Resource Edit View
Add Class to Wrap the New Dialog Step #1 – invoke class wizard
Confirm Addition of New Class
Name New Class
Click OK to Create Class
Add Class Member Variable to Hold CRC Title
Set Name and Type of Member
Add Handler to Initialize New Dialog with Font and CRC Title
Add Delete Button to Main Dialog
Click Button in Resource Editor to Add Delete Button Handler
This is the Result
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 – see code for CRCrep. Otherwise you get compile errors. Test each server module as a stand-alone module, using its test stub, before you call it from the interface code. In this prototype there is only one server module – CRCProc. Your server modules are usually called by the interface message handlers: – They affect transformations on the application’s data in response to user inputs.
- Slides: 29