Appendix -- Review Questions and Answers

Chapter 1 Review Questions

  1. What is MSF?
  2. MSF is a collection of models, principles, and practices that helps organizations become more effective in their creation and use of technology to solve business problems.

  3. Which models are most directly related to the development of business–oriented software solutions?
  4. Most directly related to the development of business-oriented software solutions are the Team Model, Process Model, Application Model, and Design Process Model.

  5. What is the main focus of the logical design perspective?
  6. The logical design perspective views the solution from the perspective of the project team.

  7. How might a client/server application implement the three tiers of an application?
  8. A client/server application might implement the three tiers of an application by integrating the business rules into either the data source tier (a thin client/fat server model) or into the client tier (a fat client/thin server model).

  9. What are some of the benefits that MFC offers to developers?
  10. Some such benefits include the ability for developers to quickly and easily generate applications, libraries, and software components. MFC enables rapid development in all aspects of Windows programming including user interface, Internet, component technology, and database access development—all without sacrificing programming freedom and flexibility. In addition, MFC provides the AppWizard, a step-by-step visual tool that allows developers to quickly and easily generate frameworks to set up a basic application structure, and to generate code to implement fundamental application behaviors.

  11. You are writing an MFC application that will allow your network administrator to manage user accounts on an NT network. Which libraries should you install?
  12. You should install the MFC libraries for Unicode (either shared or static, according to how the application will be distributed). Internal strings used by Windows NT, such as user account names and device names, are Unicode strings, so you will need to install the Unicode libraries if you are planning to write programs that retrieve and manipulate these strings directly.

  13. What kind of data can you access through an OLE DB provider?
  14. OLE DB is capable of dealing with any type of data regardless of its format or storage method. For instance, OLE DB can access data that resides in an Excel spreadsheet, in text files, or even on a mail server such as Exchange.

Chapter 2 Review Questions

  1. What project configurations are created for you automatically by the MFC AppWizard?
  2. AppWizard automatically creates the Debug and Release configurations.

  3. Where, in the AppWizard, can you configure features of the application windows?
  4. You can configure features of the application windows on the Window Styles tab of the Advanced Options dialog box in Step 4 of the AppWizard.

  5. What kinds of help are available from the Visual C++ IDE?
  6. The Visual C++ IDE provides help from the MSDN library, an essential reference for developers, containing more than a gigabyte of technical programming information.

  7. What can you set on the C/C++ tab of the Project Settings dialog box?
  8. From the C/C++ page of the Project Settings dialog box, you can set compiler settings and language features such as calling conventions, processor-dependent settings, optimizations, and preprocessor definitions.

  9. Why might you need to use the Get Latest Version feature of Visual SourceSafe?
  10. You might need to use the Get Latest Version feature to make sure that you have the latest version of all files in a project. You might also use the Get Latest Version command to copy the current versions of the project source files to your working folder, in case you make changes that render your code incompatible with other recently edited modules.

  11. Under what circumstances might you use the Visual SourceSafe Merge facility?
  12. You might use the Merge facility to merge the changes made to different versions of the same file to recreate a single version of the file.

Chapter 3 Review Questions

  1. When developing an MFC application, under what circumstances might you need to call the Win32 API directly?
  2. When developing an MFC application, you might need to call the Win32 API directly when you need to access system functionality at a fairly low level. For example, if you were developing a utility to modify user accounts on a network, you would be required to use the Win32 networking functions because no MFC classes that provide access to Windows NT network management functions exist.

  3. What services are provided by the CObject class?
  4. The CObject class provides serialization (loading and saving data objects to a agnostic and debugging support (validations and dumps), and compatibility with collection classes.

  5. Why would you use an MFC extension DLL?
  6. Because MFC extension DLLs implement reusable classes derived from existing MFC classes, you would use an MFC extension DLL to provide an "extended" version of MFC.

  7. Which member function of which MFC class implements the application message loop?
  8. The Run() member function of the CWinApp MFC class implements the application message loop.

  9. What type of classes can implement message maps?
  10. Classes derived from the CCmdTarget class can implement message maps.

  11. Name four categories of Windows messages that can be handled by message maps.
  12. Four categories of Windows messages that can be handled by message maps are Windows messages, command messages, user interface update command messages, and control notification messages.

  13. What is the function of a document template object?
  14. A document template object associates a document class with a group of resources (such as menus and icons), a frame window, and a view.

  15. Which MFC class encapsulates GDI drawing functions?
  16. The MFC CDC class encapsulates GDI drawing functions.

  17. How do you ensure that the client area of your application's main window always displays an up-to-date picture of the application data?
  18. To ensure that the client area of your application's main window always displays an up-to-date picture of the application data, you should call the document's UpdateAllViews() member function whenever a document's data changes in a way that will affect its visual representation.

Chapter 4 Review Questions

  1. Which icons should you supply for an application that meets the Windows 98/Windows NT logo requirements?
  2. You must supply both standard (32x32 pixels) and small (16x16 pixels) icons for both application and document type to meet the Windows 98/Windows NT logo requirements.

  3. How do you implement ToolTip text for your toolbar buttons?
  4. To implement ToolTip text for your toolbar buttons, add the \n escape sequence, followed by the ToolTip text, to the end of the Prompt string in the Toolbar Button Properties dialog box.

  5. How can you dynamically change the text of a menu command from within your application code?
  6. To dynamically change the text of a menu command from within your application code, you would use the SetText member function of the CCmdUI MFC class.

  7. What is the recommended way to update a status bar indicator?
  8. The recommended method for updating a status bar indicator is to set up an array of status bar indicators associated with string IDs in the application's string table. The recommended way to update text in a status bar pane is to use an ON_UPDATE_COMMAND_UI entry in a message map to associate a user-interface update handler function with an indicator's string ID.

  9. How would you make an edit control in a dialog box read-only? Why might you want to do this?
  10. To make an edit control in a dialog box read-only, select the Read Only check box on the Styles tab of the Edit Properties dialog box. A read-only edit control can be used to convey dynamically changing text to a user.

  11. You have created a dialog box template using the dialog editor. How would you display a modal dialog box, based on this template, in your application?
  12. To display a modal dialog box based on a template created using the dialog editor, you would first use ClassWizard to create a dialog class based on the template. You would then create an instance of the dialog class in your code, and call the base class method CDialog::DoModal() to display the dialog box.

Chapter 5 Review Questions

  1. How is the DoDataExchange() function called? How does it determine the direction of the data exchange?
  2. The DoDataExchange() function is called by the CWnd::UpdateData() function. The DoDataExchange() function passes data between the dialog box controls and the application; the CDataExchange class member variable m_bSaveAndValidate indicates the direction of the data exchange.

  3. How do you make controls unavailable in a dialog box?
  4. To make controls unavailable in a dialog box, you would use the CWnd::EnableWindow() function with the argument FALSE.

  5. Which two functions are used to specify coordinate mapping for an unconstrained mapping mode?
  6. The two functions used to specify coordinate mapping for an unconstrained mapping mode are the CDC functions SetWindowExt() and SetViewportExt().

  7. Which function associates a drawing tool object with a device context?
  8. The CDC::SelectObject() function associates a drawing tool object with a device context.

  9. What kinds of threads must be created by using a CWinThread object?
  10. You should always use the CWinThread class to create threads that use MFC functionality, because the CWinThread class uses thread-local storage to manage information specific to the thread context in the MFC environment.

  11. What is the difference between a CCriticalSection object and a CMutex object?
  12. Though both objects are synchronization classes, CCriticalSection allows only one thread from within the current process to access an object, while CMutex allows only one thread from any process to access an object.

  13. How are Help context IDs specified in a Help project file?
  14. Help context IDs are stored in files with the .hm extension as part of the Help project.

  15. How do you create a hyperlink in a Help project .rtf file?
  16. To create a hyperlink in a Help project .rtf file, you would format the links as double-underlined text and follow the links immediately by the link destinations formatted as hidden text. A pound (#) footnote mark signifies the link destinations. The footnote text contains the context name, which can either be a name internal to the Help file, or one of the Help context IDs specified in the Help project's .hm file.

Chapter 6 Review Questions

  1. How do you open a file in text mode?
  2. To open a file in text mode, create a CStdioFile object and associate it with the text file, and then supply the CFile::typeText flag to the Open() function.

  3. What kind of exception is thrown by the CFile::Open() function?
  4. The CFile::Open() function throws a CFileException.

  5. What steps are necessary to make a class serializable?
    • Derive the class from CObject or a class that was derived from CObject.
    • Provide a default constructor for your class.
    • Add the MFC macro DECLARE_SERIAL to the class definition.
    • Add the IMPLEMENT_SERIAL macro to your class implementation file.
    • Provide an override of the CObject::Serialize() function for your class.

  6. What does the default implementation of the SerializeElements() function do?
  7. The default SerializeElements() implementation performs a bitwise copy of data contained in an MFC collection to or from an archive.

  8. Which registry key should be used to store application settings that are common to all users of the computer on which the application is installed?
  9. The registry key that should be used to store application settings common to all users of the computer on which an application is installed is HKEY_LOCAL_MACHINE\SOFTWARE.

  10. Where do the MFC profile management classes WriteProfileString() and WriteProfileInt() store profile settings?
  11. The MFC profile management classes WriteProfileString() and WriteProfileInt() store profile settings to the registry key specified by the CWinApp::SetRegistryKey() function.

Chapter 7 Review Questions

  1. How can you connect an ADO application to an ODBC data source?
  2. You can connect an ADO application to an ODBC data source by using the OLE DB provider for ODBC.

  3. What is wrong with the following SQL statement?
  4.  SELECT * FROM authors WHERE au_lname LIKE M% 

    In the code provided, single apostrophes (') need to enclose M% so that the code reads 'M%'. Note that apostrophes are always used when the value in the WHERE clause is a string value, but not used when the WHERE clause value is a numeral.

  5. You need to open a CRecordset object so that you can list all the records in a database table to the printer. What value should you supply to the first parameter of the Open() function?
  6. Because you need to make only a single pass through the recordset to list the records to the printer, you should supply CRecordset::forwardonly as the first argument to the Open() function. You should always use the fastest and least memory-consumptive cursor for a given task.

  7. What does the CRecordset::GetDefaultConnect() function specify?
  8. This function specifies the data source to be used by the recordset.

  9. With which ADO object is the Errors collection associated? What does it contain?
  10. The Errors collection is associated with the Connection object, and contains specific information on provider errors.

  11. Which property of the ADO Data control is used to specify an SQL command to retrieve records from the data source?
  12. The RecordSource property specifies an SQL command to retrieve records from the data source.

Chapter 8 Review Questions

  1. What is a COM interface?
  2. A COM interface is a logical grouping of related methods identified by a GUID, known as an Interface Identifier (IID).

  3. What is a GUID, and what role does it play in COM?
  4. A GUID, or globally unique identifier, is a 128-bit numeric identifier that is guaranteed to be universally unique, and to remain unique until approximately 3400 A.D.

  5. What are the differences among in-process, local, and remote server COM objects?
  6. In-process servers, implemented as DLLs, execute within the same process as the object's client application. Local (or out-of-process) servers, implemented as .exe files, reside on the same computer as the client application, but execute in a different process. Remote servers execute on a computer remote from the clients that they are serving.

  7. How do you implement standard marshaling?
  8. You implement standard marshaling by specifying your interfaces using IDL and allowing the MIDL compiler to create marshaling code for you.

  9. What is a type library, and how is it used?
  10. A type library is a binary description that includes interface properties and methods, and method arguments. Type libraries are used in situations when high-performance development languages, such as Visual Basic 6.0, need to be able to access interface methods directly, through the vtable. To make this possible, type libraries provide the Visual Basic client with information on which data types are required by the interface methods.

  11. What are the implications of declaring your COM object to be free-threaded?
  12. COM objects that are created to support the free-threading model must be thread safe, and must provide their own synchronization code. By removing the bottleneck that is created by marshaling, free-threaded objects provide the highest performance and throughput on the server side.

  13. What issues must you consider when implementing an ActiveX control?
  14. When implementing an ActiveX control, you must take into consideration that, although the definition of ActiveX controls requires only that the control support the IUnknown interface, different containers have different requirements. Some containers require certain interfaces for a control to work, while others do not. If you want your control to work with a particular container, your control must implement the interfaces required by the container.

Chapter 9 Review Questions

  1. Describe the features provided by the templated base class CComObjectRootEx.
  2. The templated base class CComObjectRootEx provides a default implementation for the IUnknown interface methods QueryInterface(), AddRef(), and Release(). When you derive from this class, your client can use QueryInterface() to acquire an interface pointer to any interface that your COM object supports. CComObjectRootEx also provides implementations of the IUnknown methods AddRef() and Release() to perform reference counting for your object.

  3. Describe the features provided by the templated base class CComCoClass.
  4. The templated base class CComCoClass provides a default implementation of a class factory, which creates an instance of your server class.

  5. What is a COM map and how is it used?
  6. A COM map is an element of your class declaration that contains a list of the interfaces that your COM object supports. Add an entry to the COM map by using the COM_INTERFACE_ENTRY macro. Whenever a client application executes QueryInterface(), the object searches this map for a matching interface GUID. If a match is found, the corresponding interface pointer is returned to the client.

  7. What is an object map and how is it used?
  8. An object map is a table that maintains information used by the framework to instantiate objects through a class factory, establish communication between a client and the root object in the component, perform lifetime management of class objects, and enter and remove object descriptions in the system registry. You can add an entry to the object map by using the OBJECT_ENTRY macro.

  9. How are the keywords interface, coclass, and library used in IDL, and how do they relate to each other?
  10. In an IDL file each COM object definition is identified by a separate coclass section, and each interface definition by a separate interface section. The server's type library is defined within the library section. The coclass definitions that are to be exposed through the type library are nested within the library definition.

Chapter 10 Review Questions

  1. What kind of class represents a COM interface in C++?
  2. COM interfaces are represented in C++ code by abstract classes.

  3. How does a _com_ptr_t object help you control the lifetime of a COM server?
  4. A _com_ptr_t object helps manage the lifetime of your COM server object by calling the IUnknown::AddRef() and IUnknown::Release() methods of the encapsulated interface on your behalf. AddRef() is called automatically when a _com_ptr_t object is created as a copy from an existing interface pointer, and Release() is called automatically when a _com_ptr_t object goes out of scope.

  5. What are the advantages and disadvantages of COM containment?
  6. An advantage of COM containment is that the interface on the containing (outer) object can control access to the contained (inner) object, and can control the way in which the inner object's services are used. A disadvantage of containment is that some overhead is incurred by the forwarding of method calls.

  7. What is the purpose of the second argument to CoCreateInstance()?
  8. When an outer object creates an aggregated inner object, it uses the second argument of the CoCreateInstance() function to pass the address of its IUnknown pointer (the controlling unknown) to the inner object's class factory. If this address is not NULL, the inner object knows that it is being aggregated, and delegates IUnknown method calls from external clients to the controlling unknown.

Chapter 11 Review Questions

  1. How do you implement property persistence for an MFC ActiveX control?
  2. To implement property persistence for an MFC ActiveX control, you use the property exchange functions provided by MFC, which allow you to serialize properties of different types. The names of these functions begin with the prefix PX_. PX_ functions are placed within the control class's DoPropExchange() function.

  3. What is the purpose of the DDP functions, and where are they used?
  4. The purpose of the DDP functions is to transfer data between property pages and control properties. These functions are used within the DoDataExchange() function of the property page class.

  5. What is a connection point?
  6. A connection point is an interface that helps to manage the connection of source interfaces to a corresponding client object, or sink. Through the connection point mechanism, a pointer to the sink interface is passed to the source object. This pointer provides the source with access to the sink's implementation of its interface methods.

  7. How does an object derived from CComControl handle Windows messages?
  8. A CComControl-class object handles Windows messages by implementing a message map.

  9. What situations are best suited to using MFC to implement your ActiveX control?
  10. MFC greatly simplifies the process of creating an ActiveX control. Using the MFC ActiveX ControlWizard, you can quickly and easily create a fully featured ActiveX control. ActiveX controls written in ATL are smaller than their MFC counterparts, and if written properly will perform better. Use MFC where ease and speed of development are more important to you than the size and performance of the control.

Chapter 12 Review Questions

  1. What is the preferred method of creating a Web browser–style application?
  2. The preferred method of creating a Web browser–style application is using the MFC AppWizard, and specifying CHtmlView as the view class.

  3. In an ATL HTML control, how do you define methods to be accessible to the HTML source code of the document displayed by the control?
  4. In an ATL HTML control, you define methods to be accessible to the HTML source code of the document displayed by the control by adding the methods to the UI dispatch interface that is created for your ATL HTML control project. This UI dispatch interface is used to communicate between the C++ code and the HTML UI. Script in the HTML page displayed by your control can access properties and methods defined for this interface via the DHTML window.external object.

  5. How does the Microsoft Scriptlet Component handle scriptlet custom events?
  6. The Scriptlet Component routes all custom scriptlet events through a single event named onscriptletevent. This event is fired with two parameters. The first parameter specifies the name of the event; the second parameter can be used to pass data associated with the event.

  7. How can you save changes to ActiveX documents deployed on a Web server?
  8. You can save changes you make to an ActiveX document by using the Save As option from the File menu to create a new version on your own hard disk. An ActiveX document server won't let you save any changes you make to the document back to the Internet host.

  9. How do you specify which menu commands of the ActiveX server application are displayed by an ActiveX document container when it loads an ActiveX document?
  10. When an ActiveX document container loads an ActiveX document, it displays the menu commands defined on the IDR_SRVR_INPLACE menu of the ActiveX document server. Edit the IDR_SRVR_INPLACE menu (and toolbar) to make the appropriate items appear.

  11. How do you specify the default function for an ISAPI server extension?
  12. Specify the default function for an ISAPI server extension by using the DEFAULT_PARSE COMMAND macro in the PARSE MAP of your ISAPI extension class.

  13. How do ISAPI server extensions and ISAPI filters differ in the way they are loaded?
  14. Though both ISAPI server extensions and filters are implemented as DLLs, ISAPI server extension DLLs are loaded into the IIS process when a client first requests them, and stay loaded until the WWW service is stopped. ISAPI filters are loaded when the WWW service is started.

Chapter 13 Review Questions

  1. What is Structured Exception Handling?
  2. Structured Exception Handling is a service of the Windows operating system responsible for locating and calling handler code in an application when an error occurs. The application encloses code within a __try block and identifies its error handler code by placing it within an __except block.

  3. What is an HRESULT?
  4. In COM programming, an HRESULT is a defined type for a 32-bit-long integer containing an error code. COM components such as ActiveX controls export functions (or methods) that return HRESULT codes. An HRESULT integer contains bit fields that specify severity, facility, and a code descriptor. HRESULTs are signed integers; zero or a positive value indicates success, whereas a negative HRESULT indicates failure and usually causes an exception to occur.

  5. Name two ways in which a COM server communicates an error to a client.
  6. A COM server can indicate an error has occurred by returning an HRESULT code or by firing the Error event.

  7. How does a debug version of a program differ from its release build?
  8. Debug and release builds differ in two main characteristics. First, a program's debug build contains symbol information placed in the object code by the compiler, whereas the release code does not. Second, code in a debug build is not optimized, ensuring that the generated object code closely matches the original source code. Release code is almost always optimized.

  9. Describe MFC's ASSERT, VERIFY, and DEBUG_NEW macros.
  10. ASSERT and VERIFY are very similar, differing in only one respect. Both macros take an expression as a parameter and cause an exception if the expression evaluates to FALSE. The only difference is that ASSERT does nothing in release builds, whereas VERIFY works in both debug and release code.

    DEBUG_NEW replaces calls to the new operator, performing the same service but also recording the file name and line number where each new statement occurs. This can help locate the cause of memory leaks resulting from a failure to match a new statement with a delete statement.

  11. How does a debugger cause a running program to interrupt itself?
  12. You can place debug breakpoints at designated locations in the program. When the program you are debugging encounters a breakpoint, execution freezes and the debugger gains control. Two types of breakpoints exist: location and data. Visual C++ also provides conditional and message breakpoints, but these are simply special cases of location breakpoints.

  13. What utility does Visual C++ provide for running and testing ActiveX controls?
  14. Visual C++ provides the ActiveX Control Test Container, a generalpurpose container program that can embed any ActiveX control. The Test Container can call methods, set and read properties, activate the control's property sheet, and monitor events.

  15. What is a dependency?
  16. A dependency is an executable module, usually a DLL or an ActiveX control, that an application requires to execute. Dependencies can themselves have dependencies, forming a hierarchy of modules. For example, an MFC application might make no direct use of the C run-time library; nevertheless, the application is dependent on the library because MFC itself requires the C run-time library.

  17. What information is contained in the four lists that Spy++ can display?
  18. Spy++ can display views of current windows, processes, and threads. It can also display a log of messages that a window sends or receives.

  19. What is regression testing?
  20. In regression testing, an application is re-submitted to the same battery of tests it has already gone through. Regression testing is applied after changes are made to an application, and ensures that the changes do not introduce new bugs or unexpected behavior.

Chapter 14 Review Questions

  1. What are the two stages of deployment?
  2. The first stage of deployment is the transfer of all necessary files to the user's hard disk. The second stage involves configuring the host system so that it recognizes and correctly runs the installed application.

  3. What are cabinet files and registry files?
  4. Recognizable by their .cab extensions, cabinet files contain collections of files in compressed form. Registry or .reg files hold scripts that can be merged into system registries using the RegSvr32 utility.

  5. What is the purpose of the InstallShield tool?
  6. Given a Visual C++ project, InstallShield creates an installation package consisting of a Setup program, cabinet files, and miscellaneous information files. When run on another computer, the installation package installs the application and automatically configures the computer to run it.

  7. Must ActiveX controls be registered on a system before they can operate? If so, what examples can you give of a control's registry information?
  8. ActiveX controls must be registered on a system before they can be used. Usually, this process is hidden from the user because it is performed automatically by a Web browser or by installation programs. The registry information must include the control's class identifier and its location on the system's hard disk.

  9. Name three modes of application deployment.
  10. Applications can be deployed on media such as disks and CD-ROMs, and over a network or the Internet.

  11. What is the main advantage ATL offers over MFC when used to develop ActiveX controls?
  12. The main advantage ATL offers ActiveX development is that ATL can create controls that have no dependencies. Properly written, an ActiveX control created from ATL requires neither MFC nor the C run-time library, ensuring that only the control's executable file needs to be downloaded from a Web page. ActiveX controls created using MFC can execute only when MFC42.dll and MSVCRT.dll are present on a system.

  13. What are two common ways ActiveX controls are licensed?
  14. Licensing schemes can take many innovative forms, but generally rely on the presence of either a specific file or a particular entry in the system registry.

  15. You have created a licensed ActiveX control and have sold a copy to a development company. Should you provide them with a copy of the control's license as well? Why or why not?
  16. Yes, you should provide a copy of the license along with the product itself. ActiveX controls are sold to other developers, who in turn use them to create applications or Web pages designed for users. Licensing code prevents a developer from using an ActiveX control except in the presence of a valid license. When a developer adds an ActiveX control to an application project, the control confirms the existence of the license; only upon confirmation that the license exists can the control then be used.

  17. Name two characteristics of an ActiveX control designed for use on a Web page.
  18. An ActiveX control should be small in size, and if it requires large blocks of data, be able to load the data asynchronously. Asynchronous loading allows the control to interact with the user as quickly as possible while buffering downloaded data in the background.

  19. What is Zero Administration for Windows?
  20. Zero Administration for Windows (ZAW) is a Microsoft initiative designed to reduce the cost and labor associated with administering a Windows-based network.



Microsoft Press - Desktop Applications with Microsoft Visual C++ 6. 0. MCSD Training Kit
Desktop Applications with Microsoft Visual C++ 6.0 MCSD Training Kit
ISBN: 0735607958
EAN: 2147483647
Year: 1999
Pages: 95

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net