Steps to Build Dialog Window Recipe Application Jim
Steps to Build Dialog Window Recipe Application Jim Fawcett CSE 775 – Distributed Objects Spring 2004 Dialog. Recipe
Running Application Dialog. Recipe 2
Goals of Project · Accept text entered into the top Edit. Box. · Transfer text to the second Edit. Box as it is typed – illustrates use of text controls. · When user hits Enter key or the OK button the contents of the top edit box will be converted to a floating point number if possible. – We do this using a server module to handle the conversion. This illustrates how to use servers, developed with console-based test stubs, with a windows program. – Note that you must #include “stdafx. h” at the top of every *. cpp file in your server implementation. Dialog. Recipe 3
Construction Steps – App Wizard · · · Run Application Wizard Select MFC App. Wizard (exe) Select Dialog-based Pull controls from control palette onto dialog in Resource View. Add message handlers for every event you want to handle. – You can either right-click on dialog class in Class View to add handler – Or you double click on the control you want to handle, e. g. , Edit. Box or Button. – When you double click, you get a handler for the most common message for that control. That may or may not be what you want. – You get more control by using the first method. The second method is faster. · · Add code in message handlers, perhaps by calling a server module providing the computational engine for your interface. Compile, Edit, and Run repeatedly until you get the behavior and appearance you want. Dialog. Recipe 4
Resulting Dialog Structure Dialog. Recipe 5
Select MFC App. Wizard (exe) Dialog. Recipe 6
Select Dialog based Application Dialog. Recipe 7
Leaves You in Resource Editor Dialog. Recipe 8
Use Control Palette to Populate Dialog. Recipe 9
Right Click on CDialog. Recipe. Dlg Dialog. Recipe 10
Select Add Member Variable Dialog. Recipe 11
Add CString and double Members Dialog. Recipe 12
Right Click on CDialog. Recipe. Dlg and Add Windows Message Handler Dialog. Recipe 13
Add Code, Compile, and Run Dialog. Recipe 14
Create Server for Computational Engine Dialog. Recipe 15
Add Header and Implementation Files for Server Module Dialog. Recipe 16
Add Code for Server Header Dialog. Recipe 17
Add Code for Server Implementation Note #include “stdafx. h” Dialog. Recipe 18
Set Test Stub Pre. Proc Statement Dialog. Recipe 19
Need Debug Multithreaded for stdafx. h Dialog. Recipe 20
Test Server for Computational Engine Dialog. Recipe 21
Double Click on OK Button to Add Handler Dialog. Recipe 22
Result is This Remove CDialog: : On. OK Dialog. Recipe 23
Add Code to On. OK Handler Using Server Module Dialog. Recipe 24
Set Focus To Top Edit. Box Set Focus to Top Edit. Box, also add this to On. Init. Dialog member Dialog. Recipe 25
Running Application - Entering Text Dialog. Recipe 26
Gets This Result Dialog. Recipe 27
Structure of Dialog. Recipe Project Dialog. Recipe 28
Closing Notes · · Test application by compiling and running each time you add a new Windows Message Handler Make sure you #include “stdafx. h” in every cpp file in your server code. Make sure you #include “server. h” files in the dialog implementation file where the server is used. Test each server module as a stand-alone, console-based, application, using its test stub before you call it from your interface code. Dialog. Recipe 29
- Slides: 29