Final Exam
I have neither given nor
received unauthorized help in taking this exam (HONOR PLEDGE)
_________________________________ (sign here)
1) What would be the effect on the Paint4 program of changing the implementation of CFrameWnd::OnCmdMsg shown on page 564 to
Only Command Messages are subject to routing. Standard window messages are NOT.
a) eliminate the call to pView->OnCmdMsg
(but keep the other two calls to OnCmdMsg)
All of the following functions would no
longer work: (4 points total as shown below))
Command messages for the View: None
for paint4 (print is NOT prewired)
Command messages for the Document:
OnWidth: changes current width (1)
OnColor: changes current color (1)
OnUpdateWidthUI: sets check in Width menu
OnUpdateColorUI: sets check in Color Menu
Command messges for Document Template:
OnFileSendMail: Sends document in e-mail (1)
OnUpdateFileSendMail: enables/disables sned
menu item in file menu
OnFileSave: saves file (1)
OnFileSaveAs: saves file different name
b) eliminate the call to CWnd::OnCmdMsg (but keep the other two calls to OnCmdMsg)
I will accept either a) no change or b) (2 points total)
The following functions would no longer
work:
Command messages for the FrameWindow:
OnCreate: creates FrameWindow, sets for user
drawn menu (1)
OnMeasureItem: sets dimensions for user draw
menu (1)
OnDrawItem: draws color menu items
c) eliminate the call to pApp->OnCmdMsg (but keep the other two calls to OnCmdMsg)
The following functions would no longer
work: (4 points total)
Command messages for the Application:
OnFileNew: sets up an empty document (1)
OnFileOpen: opens and serializes in an
existing document after saving previous (1)
OnAppAbout: Displays about dialog 91)
OnOpenRecentFile: opens file in MRU part of
File menu
OnAppExit: checks unsaved documents, exits (1)
Answer by giving the specific effect (if any) on the running of
Paint4 given in this chapter (e.g. what would be affected and
how).
2) On page 570, describe the message routing sequence for the MENUITEM for ID_APP_EXIT. Give every object which is involved in routing this message from the object which receives the initial mouse button up event to the object which finally handles this message. (1 point for each of the following 8 objects)
3) What would be the effect of rearranging the POPUP menu items on page 570 so they looked like this?
POPUP "&Width" { MENUITEM "Very &Thick\tF9", ID_WIDTH_VTHICK MENUITEM "Thic&k\tF8", ID_WIDTH_THICK MENUITEM "&Medium\tF7", ID_WIDTH_MEDIUM MENUITEM "Thi&n\tF6", ID_WIDTH_THIN MENUITEM "&Very Thin\tF5", ID_WIDTH_VTHIN }
Appearance of Menu is changed (4 points), but functionality is the same(4).
4) Trace the Message for ID_FILE_NEW in Paint4.
a) Describe all users actions which will
result in the message handler of ID_FILE_NEW message being
called. (4 points as shown below)
b) For each method of invoking this handler, describe the path taken (all objects touched).
c) describe which, if any, code listed on pages 569-586 is called after the message handler is called.
THe message handler we are talking about is OnFileNew in
CWinApp
In CPaintDOc, DeleteContents (1) then OnNewDocument(1)
I assume that saving previous document is necessary because of
modified flag preceeds the call to the OnFileNew Handler
Serialize (1), initialize view(I don't have book in front of me on this one) (1 point)
Although 4 points coudl be gotten - I expected only 2.
5) Consider the RPC Audio Message Server developed in the
notes:
a) could this server support a client simultaneously recording
and playback messages? Explain
Yes - RpcServerListen specifies 5 concurrent calls - It does not matter if these are from the same client or not. (4)
The only restriction is that imposed by CreateFile which will prevent the same file from being opened simulataneously by two clients (1)
b) could this server handle multiple clients simultaneously? Explain
See a) above (4)
6) Consider the Mandelbrot Set program listing on page 426. What is the advantage of creating a thread for the MandelThread function?
TO keep main thread available for user interface events. Since the RPC calcuation will take a long time, want ot be able to stop, resize, exit in the middle of computing the set. (6)
7) Consider the Client program "labdriv.cpp"
given in the notes on Distributed Objects.
a) What would be the effect of removing the
three calls to "Release"?
The object would live forever. (hypothethically)
b) Suggest ways to handle the premature
termination of a client which is accessing distributed objects
(not specific to COM, CORBA).
Here are several (4 points for any one)
8) Consider the DLL implementation of the stack on pages 763-766. Would it be possible to eliminate the calls to "init" and/or "destroy"? Explain. (8 points)
Yes. The application would have to initialize the "top" pointer to NULL before using the stack and it would have to POP all elements off the stack to destroy it.
9) Consider the role that the CLine class plays in the
Document/View architecture with respect to the provided
"Serialize" function. (4 points each part)
a) What user actions ultimately trigger a call
to CLine's Serialize?
Open/Save file (either by mouse or accelerator)
b) Trace the relationship between CPaintDoc's
Serialize and CLine's Serialize. That is, how does CLine's
Serialize get called?
CPaintDoc calls CObjArray's serialize - which is an array of pointers to objects- which uses the virtual overloaded serialze on the object being pointed at - thus calling CLine's serialize.
10) Consider the statements from the IDL file listed on page
438 shown below.
a) Describe what information should be present
in the packet being sent from the client to the server (3 points)
All the [in] parameters (left, right, y, width)
b) Describe what information should be present
in the packet being sent from the server to the client.
All the [out] parameters (short line array)
NOTE: width need not be sent - since the client knows it and
sends to server above)
c) Describe the role of the MIDL compiler in
making the RPC mechanism work for this function call.
void CalcLine([in] double left, [in] double right, [in] double y, [in] long width, [out, size_is(width)] short line[]);