COP4226 Assignment 1
Due Thursday May, 23 at the start of class.
Hand in printouts of all the files that you change. Hand in a disk with all
the files, excluding the Debug directory.
Create a Windows application as follows:
-
Rename the View and Dialog classes so that they include your user name.
-
All member variables that you create should have your user name in them.
-
All member functions where you are given the option to create the name, should
have your user ID in them. You do not need to change the name of LBUTTONDOWN
and others like it.
-
Base the view on CScrollView.
-
Insert code so that the scroll bars will respond to the Home, End, Right,
Left, Up, Down, PageUp and PageDown keys.
-
The total size of the scroll view should be 8.5 x 11 inches. Use an appropriate
mapping mode.
-
Select a default font and make it bold.
-
Use a Font Dialog to allow the user to select a font. The Font Dialog should
appear when the user presses the right mouse button.
-
Create a modal dialog window with the following controls. The modal dialog
should appear when the user presses the right mouse button and the control
key.
-
A multi-line edit control. The text should wrap inside the control.
-
A radio list for at least three colors. This radio list will affect how the
text from the multi-line edit is drawn. It does not effect the dialog colors
in any way.
-
A dropdown combo box that has at least four options. Each option should be
a complete sentence, not just a single word. Allow a vertical scrollbar if
there are more options than will fit in the dropdown area.
-
Another radio list of the same three colors. This radio list will affect
how the text from the combo box is drawn in the view. It does not effect
the dialog colors in any way.
-
Add static controls as labels for each of the above controls.
-
Choose a nice color for the background of your dialog box. Be sure that all
of the static controls have the same background color, and choose an appropriate
text color for the static controls.
-
Create a horizontal scroll bar that will control the x-coordinate of where
to place text for the multi-line edit in the view. The range should be from
0 to 8.5 inches, with 0.5 inch increments. Be sure to handle the line, page
and thumb messages.
-
Create a vertical scroll bar that will control the y-coordinate of where
to place text for the multi-line edit in the view. The range should be from
0 to 11 inches, with 0.5 inch increments. Be sure to handle the line, page
and thumb messages.
-
Have an OK and a Cancel button. Do not allow the ESC key to cancel the dialog.
Do not allow the ENTER key to close the dialog.
-
After the modal dialog is complete, draw the text from the multi-line control
using the appropriate color. Draw the text from the combo box control using
the appropriate color. Use the font that was selected by the user, or the
default font if the user has not selected a font. Draw the multi-line edit
at the point selected in the modal dialog. Draw the other line of text directly
below the first line so that it doesn't overlap the first line.
-
If the user changes the font using the Font Dialog, then redraw the page
using the new font.
-
Allow the user to drag either line of text anywhere in the view. The text
should be able to be selected and dragged individually.
-
The user should be able to select both lines of text by clicking on one line
of text, and then pressing the CTRL key while clicking on the other line
of text. The user should then be able to drag both lines of text together,
maintaining the original relationship between them.
-
While dragging a selection, if the mouse gets within 10 pixels of an edge,
then scroll a line in that direction. If the mouse goes beyond 10 pixels
past the edge outside of the window, then scroll a page in that direction.
You only need to have the scrollbars move when the mouse moves.
-
When the modal dialog is displayed again, be sure that the users most recent
selections are displayed.
-
Extra Point: Add a check box to the modal dialog dynamically. Also add a
static label. If the box is checked then you will swap the text and background
colors when you draw all of the text in the view. You will need to modify
the data exchange function for your dynamic control.
Extra Information
-
There is a structure named LOGFONT that can hold all the characteristics
for a font. There is a member function of CFontDialog that will retrieve
the font info into a LOGFONT structure. There is also a CFont function that
will create a font from a LOGFONT structure. Look at the on-line documentation
for info about the LOGFONT structure. When you retrieve the LOGFONT structure,
the height and width will be in the FontDialog's logical units which are
MM_TEXT. You will need to translate them to logical units for the view. Use
a temporary LOGFONT to create the font, so that you don't recursively alter
the height and width.
-
Use the GetTextExtent function if you need the dimensions of a line
of text. You used this function in Ex05a.
-
To test for if the control key is pressed at the same time as the left button,
use the nFlags parameter to OnRButtonDown. The flag for the control key is
MK_CONTROL. To test if it is set, use the bitwise AND operator (&): nFlags
& MK_CONTROL.