![]() |
|
#1
|
|||
|
|||
Help! Some basal questions about MFCThis is my first step to learn MFC,when i do the exercise,so many difficult promblems puzzled me.Even more,the book doesn't have any key.I am so at sea now,so i wish a good sort could help me.Sincerely thinks!
1. Which two methods are exposed by the Dispatch interface but not exposed by the IUnknown interface? (Choose two.) A. Queryinterface B. GetTypeInfo C. Invoke D. AddRef 2. You create your own dialog class that requires the use of DDX. You add an edit control named m_cEdit to your dialog box. Using ClassWizard, you associate this edit control with a CString member variable named m_strEdit. Your dialog box has an OK button for which you add a handler that is activated when the button is clicked. Your OK button handler contains the following code: void CMyDialog::OnOK() { CDialog::OnOK(); // TODO: update m_strEdit with the contents of m_cEdit //HERE. } You must write the code indicated by the //TODO comment. Which code fragment should you insert in place of the //TODO comment? A. int nLength = m_cEdit. SendMessage(WM_GETTEXTLENGTH)+1; m_cEdit.SendMessage(WM_GETTEXT,(WPARAM) nLength, (LPARAM) m_strEdit.GetBuffer(nLength)); m_strEdit.ReleaseBuffer(); B. UpdateData(FALSE); C. m_CEdit.GetWindowText(m_strEdit); D. No additional code is needed. MFC automatically updates m_strEdit with the contents of m_ cEdit. 3. You are creating a dialog box with customized controls. You create a new class that is derived from the CButton class. You add specialized behavior code. You now want to apply the class to a button control in your dialog box. How can you associate the new class with the button control? A. Use me Add Class button on the Member Variables tab. B. Use the Add Variable button on the Member Variables tab. C. Use the Add Class button on the Automation tab. D. Select the button ID, select the newly created class, and double-click BN_CLICKED on the Message Maps tab. 4. You write an application by using MFC. This application is used to calculate taxes. Your application displays a dialog box for the entry of taxpayer information. One of the controls in the dialog box is an edit box for the entry of the taxpayer ID number that is assigned by the government. One of the digits of the taxpayer ID number is a checksum digit. When a checksum formula defined by the government is applied to the other digits of the taxpayer ID number, the result should match the checksum Digit. You will incorporate this formula into your program to ensure that the user enters a valid taxpayer ID number. What should you do? A. When the dialog box receives an EN_KILLFOCUS notification from the edit control, search a list of taxpayer ID numbers with calculated checksums. B. When the dialog box receives an EN_KILLFOCUS notification from the edit control, calculate the checksum and compare it to the checksum digit. C. When the dialog box receives an EN_UPDATE notification from the edit control, calculate the checksum and compare it to the checksum digit. D. When the dialog box receives an EN_CHANGE notification from the edit control, calculate the checksum and compare it to the checksum digit. 5. You are developing an MFC-MDI application that uses DDX. One of the requirements for your application is that the data between each form view and its dialog box controls must be updated through DDX whenever the form view is activated or deactivated. To fulfill this requirement, you override OnActivatcView for your form view. Your form view's OnActivateVicw contains the following code: void CViewl::OnActivateView(BOOL bActivate, CView* pActivatcVicw, CVicw* pDcactivcVicw) { //TODO: store/restore dialog control data HERE. CFormView: :OnActivateView(bActivate, pActivateView, pDeactiveView); ) You must write the code indicated by the //TODO comment. Which code fragment should you insert in place of the //TODO comment? A. UpdateData(bActivate); B. UpdateDialogControls(this, bActivate); C. UpdateData(!bActivate); D. UpdateDialogControls(this, !bActivate); 6. You want to use a form view in your MFC-MDI application. You add a Close button to the dialog resource that will be used with the form View. You then add to the form view class a button click handler for the Close button You want the button click handler for the Close button to close the MIDI child window that contains the form view. What must you do in the button click handler of the Close button to accomplish this goal? A. Post the WM_CLOSE message to the form view. B. Call the DestroyWindow function on the form view. C. Post the WM_CLOSE message to the parent frame window of the form view. D. Call the DestroyWindow function on the parent frame window of the form view. 7. You are writing a Windows-based application by using MFC. Your application uses a CForm View-derived object to manage a dialog box. You add the Microsoft Web Browser control to your project. You drag the control to your dialog box, but you do not see the control when Visual C++ is running in debug mode. How can you make the Web Browser control appear? A. Use ClassWizard to associate a CWebBrowser2 member variable with the control. Call the variable's Create function in the OnInitialUpdate method of the CForm View-derived Object. B. Use ClassWizard to associate a CWebBrowser2 member variable with the control. Call the variable's Navigate function with a valid URL in the OnInitDialog method of the CFormView-derived object. C. Use ClassWizard to associate a CWebBrowser2 member variable with the control. Call the variable's SetVisible function in the OninitDialog method of the CFormView-derived object. D. Use ClassWizard to associate a CWebBrowser2 member variable with the control. Call the variable's SetRegisterAs Browser function in the OninitialUpdate method of the CFormView-derived object. 8. Your Visual C++ application uses an ADO Data control along with a number of edit controls to display inventory data for your company. Changes to the inventory must be validated by code within your application before the changes are written to the database. For which event should you write a handler? A. the WillChangeRecordset event of the ADO Data control B. the WillChangeRecord event of the ADO Data control C. the Validate event of the ADO Data control D. the EN_KILLFOCUS message of the appropriate edit control 9. You write a Windows-based SDI application that uses a set of Microsoft Windows controls for input. To simplify the design of your application, you create a form by using the Visual C++ resource editor. You derive a class from the standard MFC CFormView class, and you use this class as the default view in your application. You want to resize the main frame window of the application to match the size of the form you have designed. What should you do? A. Override the CFrameWnd::Create function in your frame Window class. Call the CFrameWnd::Create function, passing a RECT argument specifying the size of your form. B. Override the CformView::OnInitialUpdate function in your derived class. Call the CWnd::SetWindowPos function to change the parent frame to the size of your form. C. Override the CFormView: D. Override the CFormView:OInitialUpdate function in your derived class. Call the GetParentFrame()->RecalcLayout and ResizeParentToFit functions. 10. You are modifying a change-password dialog box for a number of applications that are used internally by your company. You arc using an edit control named Editi to accept the user's password. You want to require a minimum length for passwords. You also want the control to retain focus until the user has entered a password that is valid by company rules. What should you do to meet these requirements? A. Superclass the edit control. B. Subclass the edit control. C. Use the GetDlgItem function in the edit control's OnChangeEdit1 function. D. Use the OnOK function of the dialog box. 11. You are designing an ActiveX user interface control. You need to decide which properties should be accessed by Get/Set statements, and which properties should be member variables. Which two properties should be implemented by using Get/Set statements? (Choose two.) A. a property that represents an integer variable with values from 1 to 10. B. a string variable C. an Automation class variable D. a bounded array of long variables E. a float variable 12. You will use Visual C++ to create an application to manage a mailing list for a group of hobbyists. You want to keep mailing-list data as a set of character strings that will represent name, address, telephone number, e-mail address, and other information. The user will enter each field in the mailing list through a standard edit control. To minimize development and debugging labor, you want to use prewritten and wizard-generated code as much as possible. What should you do? A. Define a dialog box containing a separate edit control for each data field to be entered. Open this dialog box from an item on the application's File menu. Call the GetDlgItemText function to read strings from each control. B. Create a separate edit control in your application's main window for each data field to be entered . Call the GetWindowText function to read strings from each control. C. Use a dialog box as the main window of your application. Use DDX to associate strings from each control. D. Use a dialog box as the main window of your application. Call the GetDlgItemText function to read strings from each control. E. Create a Microsoft Excel worksheet for me mailing list. Write an application that contains your worksheet as an active document. 13. You are using Visual C++ to create a COM component that will scan files for conformance to validity constraints. The component might be used by many client programs at the same time. To avoid duplicate scanning, the component maintains an internal list of files it has scanned. The component does not persist this list when it unloads. Which type of COM component should you create? A. active document B. ActiveX user interface control C. out-of-process COM server component D. in-process COM server component 14. You create an ActiveX user interface control. Many application programs in your company will use the control. You want to name the control when it is embedded in an application and display the name in a title bar at the top of the control window. What should you do? A. Call IDispatch::Invoke(DTSPID_AMBIENT_DISPLAYNAME,...) B. Call I0leObject::SetHostNames. C. Store the control name in a CString member of the class that implements the control. D. Read the Name extended property that is assigned to the control by the container application. 15. You design a COM component for use by many user interface applications in your company. One of the interface methods for the component defines a parameter for an IP address as a string in the format nnn.nnn.nnn.nnn. The component's type library defines this parameter as both an input and an output parameter. When the interface method is called, the component validates the IP address. If the current user is forbidden to access that address, then the component should change the parameter to the string 0.0.0.0 and display this string within the application. Which type of COM component should you design? A. data-aware class B. distributed COM server component C. out-of-process COM server component D. ActiveX user interface Control 16. You write a loan processing application for SpringFirst Home Loans. You want to reuse two COM components from an existing application: a Customer object that encapsulates a customer's name and address, and a Loan object mat encapsulates the principal amount, interest rate, loan period, and payment history. You create a CustomerLoans object that aggregates the Customer object and maintains a list of Loan objects. A customer may have zero, one, or many loans from SpringFirst Home Loans. Which property or properties should the CustomerLoans object expose? (Choose all that apply.) A. database server name B. name of the control used to display loan amounts C. customer name D. number of active loans E. principal amount of the first loan 17. You design an application for a mail-order clothing company. Company representatives will use your application to enter customer orders. You decide to represent a customer by using a COM component. The component will contain customer information, including name, address, telephone number, e-mail address, and orders pending shipment. Each customer will be assigned a unique customer ID number. How should you represent the customer ID number? A. as an event B. as a method C. as a property D. as a recordset E. as an interface 18. You want to restrict the size of a frame window in your Visual C++ Windows-based application You add code to handle the WM_SIZE message. The frame window is now initially displayed in a large frame, and then it snaps to the correct size. In addition, a user can drag the frame to any size while holding down the mouse button. How should you restrict the size of the frame window? A. Add the code that restricts the frame size to the WM_GETMINMAXINFO message handler. B. Add the code that restricts the frame size to the AdjusWindowRectEx function. C. If the unadjusted frame window too big, resend the WM_SIZE message at the end of the WM_SIZE message handier. D. Add Me code that restricts the frame size to the ON_WM_CREATE message handler. 19. The user interface for your project will require a large number of Microsoft Windows common controls that must interact with one another. You want to minimize the amount of programming work required to complete the project. Which type of Microsoft Visual Studio project should you create? A. Win32 Application project B. Win32 Console Application project C. ATL COM AppWizard project D. MFC AppWizard(exe) project 20. You write a Windows-based application by using MFC. You create a scrolling view class by deriving from the MFC library class CScrollView. The source code that implements your class includes the following code fragment: CMyView::OnLButtonDown(UINT, CPoint point) { CCLientDC dc(this); OnPrepareDC(&dc); // program continues ... } What is the most likely result of the call to the OnPrepareDC function? A. The clipping region of the view is adjusted to the containing frame, B. The device context object is enabled for GDI calls. C. The view will disable scrolling while drawing takes place. D. The viewport origin and viewport extents are adjusted to the containing frame. |
|
#2
|
||||
|
||||
|
Do you want me to take this Quiz!?
![]() __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
More photos on Flickr by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A couple questions about Fl_Tabs | WW. | FLTK Forum | 3 | 07-Oct-2004 07:04 |
| Hello from cali, questions about web design | jonnydangerous | New Member Introductions | 3 | 20-Aug-2004 13:59 |
| Simple questions? | Netizen Dave | Apache Web Server Forum | 3 | 17-Mar-2004 04:45 |
| [Linux] Top newbie questions. | JdS | Computer Software Forum - Linux | 3 | 22-Jan-2004 12:00 |
| Web Promo Questions. | BigZ | Advertising & Affiliates Forum | 9 | 16-May-2002 08:57 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The