Code Generation:
Since CLGEN reads resource file and generates code for each control, a dialog template in the project is required before running CLGEN in most of time. Creating a toolbar requires a toolbar resource.
CLGEN creates new files and modifies existing files. If project is under source control, make sure to check out those to be modified files before running CLGEN. The most frequently updated files include project file (.DSP), classWizard file (.CLW), resource file (.RC), and resource header file (RESOURCE.H). CLGEN backup all the files before modifying them. The backup file has same name as the original file but different extension. The relationship is: .DSP - .DBK; .CLW - .CLB; .RC - .RCB; .H - .HBK; .CPP - .CBK.
CLGEN updates .DSP file because it adds the newly created files (normally one .H and one .CPP files) into project. It also puts library into the project if the library is needed. CLGEN only modifies this project file for Visual C++ version 5. CLGEN modifies .CLW file because it adds every newly created class into classWizard so that the new class can be edited by classWizard.
Sometimes CLGEN needs to change .RC and RESOURCE.H. For example, dialog by default is set to invisible. CLGEN sets it to visible when creating a modeless dialog, it also changes the default style from popup to child. When creating a tool bar object, CLGEN adds a new ID into the RESOURCE.H for the tool bar.
MFC has more than one way to define a control variable for some controls. For example, an edit control can be defined either as CString or as CEdit. CLGEN picks one way as default. In the case of edit control, CString is the default. If you want the control to be defined as CEdit, you need to append _CTRL in the end of the control's IDC, such as IDC_NAME becomes IDC_NAME_CTRL.
List box control - default CListBox, append _VAL to make it as CString
Combo box control - default CComboBox, append _VAL to make it as CString
Static control - default no variable defined, append _VAL to make it as CString
Edit control - default CString, append _CTRL to make it as CEdit
Radio button control - default int, append _CTRL to make it as CButton
Check box control - default BOOL, append _CTRL to make it as CButton
Currently, CLGEN generates code for modal dialog, modeless dialog, modal property sheet, modeless property sheet, property page, form view, dialog bar, and tool bar, as well as controls in the dialog template. Please go to Next page to get more details.
User Interface Customization:
There is a check box called "Picture Background" in CLGEN program. If it is checked, CLGEN will generate code to use classes defined in "JPICT" DLL. By using this DLL, you are able to convert windows application's standard gray background into picture background. JPICT provides a default pattern background, you can set your own bitmap as the background. The background can be set globally for the whole application, or for all dialogs, or set individually for each GUI object.
You can also set font and color for different GUI objects like menu and button. CLGEN can write code to set font and color for controls if you specify it in CLGEN's option dialog.
All JPICT classes (except menu) are derived from their correspondent MFC classes. They changes their base classes' visual aspects but keep other aspects the same. You can derive your own classes from JPICT classes, just treat them as MFC classes.
The procedure for CLGEN to generate JPICT classes is the same as generate their MFC base classes when "Picture Background" is checked off. The classes currently defined in JPICT include menu, toolbar, dialog bar, status bar, dialog, property sheet, property page, form view, tab ctrol, button, combo box, list box, static, radio button, check box, and group box. Please go to Next page to get more details.
Custom Edit Control:
CLGEN provides another DLL called "JEDIT". JEDIT defines a set of classes derived from CEdit. They are very useful to validate user input and to simplify coding. You can set value range and set template to guide user input by using JEDIT classes. CLGEN writes SetupEdit function in the dialog class to allow you to setup the JEDIT classes . CLGEN also writes a message handler OnJEditChar in the dialog class, which is called when a valid character is entered into a JEDIT Control. You can prevent the character from entering by returning non-zero from the function. This gives you flexibility to control user input.
You make CLGEN to generate JEDIT classes by appending a string in a edit control's IDC. For example, if a control's IDC is IDC_AGE, you change it to IDC_AGE_INT in the dialog template. CLGEN will define this control as a JEDIT integer control when it creates the dialog class. CLGEN will also copy JEDIT DLL into your project. The relationship between the appending string and the JEDIT class is:
_INT - CIntEdit
_SHORT - CShortEdit
_LONG - CLongEdit
_FLOAT - CFloatEdit
_DOUBLE - CDoubleEdit
_CUR - CCurrencyEdit
_STR - CStringEdit
_DATE - CDateTimeEdit
Numeric JEDIT classes restrict application user input to digit 0 to 9, '+', '-', and '.'. The value entered has to be inside the system range and application defined range. The normal numeric operations can be applied to these classes, which includes '+', '-', '*', '/', '=', '+=', '-=', '*=', '/=', '>', '<', '>=', '<=', and '=='. CCurrencyEdit is numeric type edit accepting extra characters: '$', ',', '(', and ')'.
CDateTimeEdit can be compared with each other, with CString, and with CTime using '==', '!=', '>', '>=', '<', or '<='. It can be converted among CDateTimeEdit, CString, and CTime using '=' operator. CDateTimeEdit makes sure user input is in the valid range and in the good date/time format. CDateTimeEdit defines six formats:
mm/dd/yyyy - SHORT_DATE (default)
month dd, yyyy - LONG_DATE
mm/dd/yyyy hh:mm a(/p)m - SHORT_DATE_TIME
month dd, yyyy hh:mm a(/p)m - LONG_DATE_TIME
mm/dd/yy - SHORT_DATE_WO_CENTURY
mm/dd/yy hh:mm a(/p)m - SHORT_DATE_TIME_WO_CENTURY
CStringEdit uses template to guide user input. It supports multiple templates for one control. For example, user can enter either (123) 456-7890 or 123-456-7890 in the control to be a valid input. If no template is set, CStringEdit accepts all input. The CStringEdit variable can be operated as a CString variable, which makes using CStringEdit very convenient. CStringEdit uses following characters as mask for the template:
'A' - upper case letters
'B' - upper case letters or digits
'a' - lower case letters
'b' - lower case letters or digits
'X' - upper or lower case letters
'Y' - upper or lower case letters or digits
'9' - digits
'?' - all characters
'\\' - make the above mask characters non-mask characters
Please go to Next page to get more information.
Document Source Code:
If you select "Documentor" from CLGEN's menu, then select a CPP file from the file dialog, CLGEN will put a document header to every function of the CPP file.
The header includes - Function Name, Author Name, Document Date, Description, Parameter list, and Return. The documentor will fill function name, date, parameter list. If the author name is put into file "cdoc.ini" in the CLGEN executable directory, the name will be added into the header. Two lines are needed in the "cdoc.ini" file:
[Author]
Author = FirstName LastName
A CPP file can be documented multiple times. The old header will not be overwritten.