- Table of Contents
- Copyright
- About the Authors
- About the Contributors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- How to Use This Book
- What You Need to Use This Book
- What's New in Visual C++ 6.0
- Contacting the Main Author
- Part I: Introduction
- Chapter 1. The Visual C++ 6.0 Environment
- Part II: MFC Programming
- Chapter 2. MFC Class Library Overview
- Chapter 3. MFC Message Handling Mechanism
- Chapter 4. The Document View Architecture
- Chapter 5. Creating and Using Dialog Boxes
- Chapter 6. Working with Device Contexts and GDI Objects
- Chapter 7. Creating and Using Property Sheets
- Chapter 8. Working with the File System
- Chapter 9. Using Serialization with File and Archive Objects
- Part III: Internet Programming with MFC
- Chapter 10. MFC and the Internet Server API (ISAPI)
- Chapter 11. The WinInet API
- Chapter 12. MFC HTML Support
- Part IV: Advanced Programming Topics
- Chapter 13. Using the Standard C++ Library
- Chapter 14. Error Detection and Exception Handling Techniques
- Chapter 15. Debugging and Profiling Strategies
- Chapter 16. Multithreading
- Chapter 17. Using Scripting and Other Tools to Automate the Visual C++ IDE
- Part V: Database Programming
- Chapter 18. Creating Custom AppWizards
- Chapter 19. Database Overview
- Chapter 20. ODBC Programming
- Chapter 21. MFC Database Classes
- Chapter 22. Using OLE DB
- Chapter 23. Programming with ADO
- Part VI: MFC Support for COM and ActiveX
- Chapter 24. Overview of COM and Active Technologies
- Chapter 25. Active Documents
- Chapter 26. Active Containers
- Chapter 27. Active Servers
- Chapter 28. ActiveX Controls
- Part VII: Using the Active Template Library
- Chapter 29. ATL Architecture
- Chapter 30. Creating COM Objects Using ATL
- Chapter 31. Creating ActiveX Controls Using ATL
- Chapter 32. Using ATL to Create MTS and COM+ Components
- Part VIII: Finishing Touches
- Chapter 33. Adding Windows Help
- Part IX: Appendix
Programming Your AppWizard DLL
When you created your custom AppWizard project, files were created in the Source Files and Header Files folders of your AppWizard project and are used to build the DLL for your custom AppWizard. In many cases, you will never need to touch these source files; you can do a great deal of customization simply by editing the template files for your AppWizard. If you are creating your own step dialog boxes or adding your own macros, however, you will need to make some modifications to this code.
Defining Macros
If you are changing anything in the source for your AppWizard DLL, you most likely will want to add your own macros that can be used in parsing the template files for new projects. This is particularly necessary if you will be creating your own step dialog boxes, because you will need some way of conveying the user's selections from your dialog boxes to the template parsing operations.
When you created your custom AppWizard project, the AppWizard created several classes for your project. One of the most important is the class derived from CCustomAppWiz, which is named according to your project name but ends in AppWiz.
To add your own macros, you need to add entries to the m_Dictionary member of the one and only object derived from CCustomAppWiz. m_Dictionary is a collection of type CMapStringToString, which contains mappings from macro name to macro text value. Generally, macros are added to the dictionary in the OnDismiss() member of your step dialog box classes.
To see how to add macros to the dictionary, look at the following example, which comes from a custom AppWizard project named MyCust (thus, the class names have MyCust in them). Your class names will be different. The member variables used in the following code, such as m_SetOption and m_DocTitle, are values that were retrieved from the user through the step dialog box.
BOOL CCustom1Dlg::OnDismiss()
{
if (!UpdateData(TRUE))
return FALSE;
else
{
if (m_SetOption)
{
// Set value of existing macro
MyCustaw.m_Dictionary["VERBOSE"]="Yes";
// Add our own Boolean Macro
MyCustaw.m_Dictionary["MYOPTION"]="Yes";
}
else
{
// Remove our option macro
MyCustaw.m_Dictionary.RemoveKey("MYOPTION");
}
// Set one of our text macro values
MyCustaw.m_Dictionary["MY_DOC_TITLE"]=m_DocTitle;
return TRUE;
} // end else
} // end OnDismiss
Creating Step Dialog Boxes
If you chose to add a number of your own custom steps when you created your custom AppWizard project, you will notice that a class for each of your dialog steps was created for you. These classes are named something like CCustom1Dlg and are derived from CAppWizStepDlg, which is in turn derived from good ole CDialog. You also should notice that dialog box templates for each of your steps were added to your custom AppWizard project.
You can develop the dialog boxes for your step dialog boxes by setting up the dialog box templates and adding code to the step dialog classes, just as you would for any other CDialog. The additional thing you generally will want to do is add code to the OnDismiss() member of your step dialog classes to add macros to the dictionary.
You might want to add even greater customization in other places in your AppWizard DLL code, but we cannot cover them all here. For more information, see Creating Custom AppWizards in the Visual C++ User's Guide in the online help.
Building a Custom AppWizard | Next Section

Account Sign In
View your cart