GUI Part II Midterm
Your midterm assignment is divided
into three tasks:
1. Create a custom, re-usable dialog that inputs a name and password.
2. Create a derived CEdit class that will perform special text-formatting.
3. Write a new test program, using the above two items, from
the component gallery.
Items 1 and 2 above will reflect a class, and that class must
be packaged into the component gallery, for re-use. You are to
hand in the project(s) for each on disk, as well as your test
programs. You are to print the source code that you make changes
too only, and hand in that printout as well.
You will also need to copy the files that were added to component
gallery, and include those on your disk.
Custom Dialog
You are to create a login
name and password dialog, similar to what appears below. If the
Login name is blank, the OK button is to be disabled.
When the user clicks OK or Cancel, the dialog will
close. This dialog will not attempt to actually 'logon' to anything,
but will simply retrieve a login name and password.
You must create a class for this dialog, called CPasswordDlg.
You must add two member variables, called m_Login and m_Password,
which will contain the user's input. Once the class is written,
you are to add the dialog to the component gallery.
Answer the following:
1. Why do static controls have an underlined character?
2. Where was the component added, in relation to the normal gallery.
3. What was the name of the file added to componenet gallery.
Custom Edit Class
Write a custom class,
derived from CEdit. When the user leaves the control (kill focus),
the text in the field is converted to properly-formatted upper
and lower case. For example, if the user typed 'mario giannini',
when they leave that field, it is automatically re-formatted to
'Mario Giannini'.
This class should have two static member functions, that permits
this feature to be turned off, or determine if the feature is
enabled or not. You will need to add:
static bool SetConversion( bool Mode );
This function will set the 'conversion status' of all CCaseEdit
objects to either do, or not do, the case conversion. Mode
will be true if they should do the conversion, false if not. The
function will return the previous conversion mode.
static bool GetConversion();
This function will return true, of CCaseEdit objects do the case
conversion, and false if not.
The above functions should be static, so that by calling the SetConversion
function to change the conversion status, you are changing it
for all CCaseEdit objects in your program (a static data member).
You will also need to add the appropriate
handler for the new class to handle the kill focus notification.
That handler is not documented here, but must be written by you
(added via ClassWizard).
Your view class should have nothing specific to the formatting
of the text string (the case conversion) in it. All this code
is to be in the CCaseEdit class.
Test program
Your test program must have the following features:
You must add the two components from the Component Gallery, that
you previously placed there, to this project.
The login dialog appears when the program first starts up, before
the main window. If the user hits cancel, the program should terminte,
otherwise it should continue as normal. Nothing more is done with
the login password class.
There will be two edit boxes on the main window. When the user
types in data, and moves between the fields, the first edit box
will automatically convert the users text to correct upper-lower
formatting. The second edit box does not have this ability (it
is a normal edit box). This conversion behavior is dependent upon
the Conversion menu item.
A Do Conversion menu item is to be added to your test program.
It is a 'checked' menu item. If the item is checked, then the
case-conversion described earlier is performed. If it is not checked,
then the case conversion is not performed. The Do Conversion
menu item should be added at the bottom of the Edit menu.
For the Do Conversion menu choice, you must provide
an accelerator key. You must add the accelerator to the Accelerators
resource. Use Control-D. You must display the accelerator in the
menu option, so take a look at how the Copy and Paste items do
it (examine their Caption property).
You will need to handle the COMMAND event for the Do
Conversion menu item to enable/disable the conversion,
and the UPDATE_COMMAND_UI event to check and un-check the
menu item.
Note: If ClassWizard does not recognize your new CCaseEdit class
in the Member Variable tab ('Control' category) after adding it
to your project, then perform the following steps:
Optional
The program may save the last status
of the user's 'Conversion Status' in the registry when the program
terminates, and read it back when it starts up again. You should
check the conversion status from the registry in the OnInitInstance
of your CWinApp class. You can set a value of "Yes"
or "No into the registry in the same function that handles
the toggling of the status, via the menu selection.
The registry Section should be 'Settings', and the entry should
be 'DoConversion'. This entry will be either "Yes" or
"No", and should have a default of "Yes" if
no entry exists in the registry.
Note: This entire assignment required me to type about 25 lines
of code!