Quiz Answers
This appendix lists the answers to the quiz questions in the Workshop sections at the end of each Section.
2. A project is built by using one of these steps:
4. AppWizard, ClassWizard, and ControlWizard
5. Press the F1 function key.
6. ClassView, FileView, ResourceView, and InfoView
7. OnDraw
8. The F7 function key
9. Ctrl+Z
10. Undo reverses an action; Redo reverses an Undo.
2. When including project-specific files that are located in the project directory, use quotes around the header filename, as in the following:
#include "myfile.h"
#include <myfile.h>
4. A C++ namespace provides a container for a set of names. This prevents identical names in two parts of your application from conflicting with each other.
5. To declare multiple variables on one line, separate the variable names with a comma, like this:
int nFoo, nBar, nBaz;
7. The floating-point variable types are float, double, and long double.
8. The C++ assignment operator is the equals sign, =, as in nFoo = 5;.
9. Integer values are normally stored in variables that have the int type. To save space, smaller values may be stored in the char and short int types.
10. If you know that a value will not be negative, you can double the maximum value stored in the variable by declaring it as unsigned.
2. A function is a group of computer instructions that are grouped together to perform a well-defined task.
3. The function's name, return value, parameter list, and function body.
4. Classes are exactly like structures, except that members of a class cannot be accessed from outside the class by default.
5. The constructor
6. The destructor
7. The non-client area contains the borders, menu, and caption area; the client area is the area that is left over.
8. 42
9. The * symbol is used for multiplication.
10. The / symbol is used for division.
2. WM_INITDIALOG
3. .h
4. .cpp
5. The warning icon, MB_ICONEXCLAMATION
6. The stop sign icon, MB_ICONSTOP
7. CDialog
8. DoModal
9. IDYES
10. IDNO
2. An OK button is used to close the dialog box and keep any changes that have been made. An Apply button keeps changes that have been made but does not close the dialog box; this button is often used when the Apply button is used to update the application that displays the dialog box.
3. CButton
4. Check boxes, radio buttons, pushbuttons, group boxes, and owner-drawn buttons.
5. Clear the Tab Stop property for the control.
6. Enable
7. ShowWindow
8. The default label is selected when no case labels match the switch expression.
9. The = operator is used for assignment. The == operator is used to test for equality.
10. SetWindowText
2. An MLE is a multiline edit control and accepts multiple lines of text as input. An SLE is a single-line edit control and accepts single lines of text as input.
3. A DDV routine is used to validate data input stored in a control. A DDX routine is used to transfer data to or from a control.
4. UpdateData
5. GetWindowText
6. SetWindowText
7. Password
8. Ctrl+V
9. Ctrl+C
10. Ctrl+X
2. LBN_DBLCLCK
3. AddString and InsertString
4. GetCount
5. GetCurSel
6. Single-selection, multiple-selection, and extended-selection
7. for, while, and do-while
8. CComboBox
9. InsertString
10. Simple, drop-down, and drop list
2. Messages are physical chunks of data and are easily prioritized. They are not processor or language dependent.
3. When the mouse cursor passes over a window, the window receives the WM_MOUSEMOVE and WM_NCMOUSEMOVE messages.
4. A message map is used to associate a message with a function used to process that message.
5. CObject is the base class for most MFC classes.
6. The Dump function is used to display debug information about the current state of an object.
7. The ASSERT macro is used to test an expression that is not needed when the program is compiled for release mode. The VERIFY macro is used to test an expression that is used when the program is compiled for release mode. When compiled for release mode, the ASSERT macro and the expression contained inside it will be removed; the VERIFY macro is also removed, but its contained expression is compiled.
8. WM_LBUTTONDOWN
9. The message map entries reserved for use by ClassWizard begin with //{{AFX_MSG_MAP and end with //}}AFX_MSG_MAP.
2. A pointer that points to one variable can be changed to point to another variable; references must be bound to a single variable for their lifetime. A reference to a class uses . to access a member, a pointer to a class uses the -> operator.
3. Passing a point to an object rather than the object itself is almost always more efficient. Passing a pointer parameter is a 32-bit variable; passing an object such as a class instance requires that a copy be made of the instance--and not only must the copy be made, it must be destroyed after the copy is no longer needed.
4. The new keyword is used to dynamically allocate memory.
5. The delete keyword is used to release memory allocated with new.
6. Classes derived from CView are responsible for the user interface.
7. The four classes are
9. The GetDocument function returns a pointer to the document associated with a view.
10. A document class uses UpdateAllViews to notify views associated with the document that their user interfaces might need to be updated.
2. The WM_CONTEXTMENU message
3. An ellipsis (...) after the menu item
4. A letter that is used to represent the menu item, such as x in Exit
5. A keyboard shortcut to a message-handling function
2. SelectStockObject
3. Approximately 1440
4. A pen
5. A brush
6. Use the GetTextMetrics function.
7. RGB is used to create a COLORREF value.
8. CDC
9. If SelectObject returns NULL, the call failed.
10. MM_TEXT
2. Cosmetic and geometric
3. CPen
4. BLACK_PEN, WHITE_PEN, and NULL_PEN
5. PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT, PS_NULL, PS_INSIDEFRAME, and PS_ALTERNATE
6. PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT, PS_NULL, and PS_INSIDEFRAME
7. Solid, hatch, pattern, and stock
8. BLACK_BRUSH, DKGRAY_BRUSH, GRAY_BRUSH, HOLLOW_BRUSH, LTGRAY_BRUSH, NULL_BRUSH, and WHITE_BRUSH
9. CBrush
10. Ellipse
2. ANSI_FIXED_FONT, ANSI_VAR_FONT, DEVICE_DEFAULT_FONT, DEFAULT_GUI_FONT, OEM_FIXED_FONT, and SYSTEM_FONT
3. The font escapement is the angle in tenths of a degree that a line of text forms with the bottom of the page.
4. A glyph is an individual character.
5. CFont
6. Decorative, Modern, Roman, Script, Swiss, and Dontcare
7. DEFAULT_PITCH, FIXED_PITCH, and VARIABLE_PITCH
8. SetFont
2. The hotspot
3. ClipCursor
4. SetCapture
5. SetCursor
6. WM_SETCURSOR
7. 16x16
8. BeginWaitCursor
2. CPalette
3. Memory DC
4. BitBlt
5. 256
6. 20
7. WM_QUERYNEWPALETTE and WM_PALETTECHANGED
8. WM_QUERYNEWPALETTE is sent to an application when it moves into the foreground. WM_PALETTECHANGED is sent to an application after the system palette has been updated.
2. Auto-buddy
3. The CSpinButtonCtrl::SetRange member function is used to set the minimum and maximum limits for an up-down control.
4. The control tab order determines which control is paired with the up-down control. The up-down control must follow the buddy control in the tab order.
5. Tick marks
6. The CSliderCtrl::SetRange member function is used to set the minimum and maximum limits for an up-down control.
7. The CProgressCtrl::SetRange member function is used to set the minimum and maximum limits for an up-down control.
2. If items are often added to the image list, the grow-by parameter reduces the number of costly internal resize operations performed by the image list.
3. A transparent image is an image that allows part of the background surface to be visible.
4. The color mask is used to determine the color in the bitmap that is treated as the transparent color. The image list uses this information to create a mask for the image.
5. ILD_TRANSPARENT
6. The ILD_BLENDxx styles are used to combine the image with the system highlight color.
7. You are always responsible for destroying the bitmap or icon used as a source for the image stored in the image list. The image list will keep a copy of the image internally.
8. An overlapped image is made up of two combined image list items.
2. Icon view uses a 32x32 icon. Small icon view uses a 16x16 icon.
3. LVN_BEGINLABELEDIT and LVN_ENDLABELEDIT
4. You will receive LVN_ENDLABELEDIT with the LV_ITEMpszText member set to NULL or the iItem member set to -1.
5. SetWindowLong
6. First, you must initialize the LV_COLUMN structure, then call CListCtrl's InsertColumn member function.
7. Call CListCtrl's SetItem text member function.
8. -1
2. TVN_BEGINDRAG is sent when the drag operation begins, WM_MOUSEMOVE is sent when the mouse is being moved, and WM_LBUTTONUP is sent when the user releases the primary mouse button.
3. The first image is displayed when the tree view item is in its normal state. The second image is displayed when the item is selected.
4. CTreeCtrl::DeleteAllItems()
5. The properties for any view can be changed in the PreCreateWindow function.
6. The TVS_HASLINES is equivalent to the Has lines property; TVS_LINESATROOT is the same as the Lines at root property, TVS_BUTTONS is the same as the Has buttons property, and the TVS_EDITLABELS style is equivalent to the Edit labels property.
7. Unlike the list view control, where items are referred to by an index, items in a tree view control are referred to through an HTREEITEM handle.
8. Images stored in a tree view control can be any size.
9. Use the TVI_FIRST symbol when calling CTreeCtrl::InsertItem:
m_tree.InsertItem( szLabel, 1, 1, hParent, TVI_FIRST );
2. Visual Fox Pro, Visual Basic, Access 95, and Delphi are just a few of the development tools that support ActiveX controls.
3. Examples of events fired from ActiveX controls include mouse clicks, pressed buttons, and expiring timers.
4. Examples of properties exposed by ActiveX controls are the font and background color used by a control.
5. A grid control, such as the Microsoft FlexGrid
6. False
7. In AppWizard step two, the ActiveX Controls check box must be selected.
8. A function that is exposed by the control and called by the control's container
9. False
2. The five MFC view functions that are most commonly overridden for printing are
5. OnBeginPrinting
6. About 1,440
7. Set the CPrintInfo::m_bContinue member variable to TRUE
8. The positive direction is up--the bottom of the page is usually a large negative number.
9. The positive direction is to the right.
10. OnEndPrinting
2. Serialization is the act of storing the state of an object for the purpose of loading it at another time.
3. Serialization is the act of storing the state of a persistent object to an archive; deserialization is the act of reading data from an archive and re-creating a persistent object.
4. CArchive
5. Serialize
6. SerializeElements