Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

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.

Share ThisShare This

Informit Network