home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / dcomdraw / dcomdraw.txt < prev    next >
Text File  |  1997-09-09  |  9KB  |  163 lines

  1.  
  2. DCOMDRAW - Client of structured storage server
  3.  
  4.  
  5. SUMMARY
  6. =======
  7.  
  8. The DCOMDRAW, DCDSERVE, and DCDMARSH samples together form a distributed
  9. drawing application. Using Distributed COM (DCOM) technology, they allow
  10. users on different client machines in a network to interactively draw on a
  11. shared drawing. All DCOMDRAW clients see the same drawing and any client
  12. can take ownership of the pen to draw. The user of DCOMDRAW can use a
  13. mouse or tablet device to draw in the client window and can choose the
  14. color and width of the electronic ink. As clients draw, the application
  15. echoes the drawing activity from DCDSERVE to all connected clients using
  16. DCOM over the network. Although these samples do not build an optimized
  17. and complete application, the functionality is suggestive of the shared
  18. whiteboards offered by some workgroup applications.
  19.  
  20. Although DCOMDRAW, DCDSERVE, and DCDMARSH work on the same machine across
  21. process boundaries, the main goal is to provide a distributed application
  22. that enables multiple DCOMDRAW clients on different machines to access a
  23. single shared drawing object housed in a DCDSERVE server running on a
  24. common server machine. A typical scenario would have numerous client
  25. machines hooked to an intranet consisting of a Windows NT network domain
  26. or peer-to-peer workgroup. DCOMDRAW can run on any of these client
  27. machines. DCDSERVE is installed and runs on a common server machine in the
  28. domain. The user of the DCOMDRAW client can interactively choose the
  29. remote server machine to determine which DCDSERVE COM server to use for
  30. the shared drawing.
  31.  
  32. DCDSERVE manages a shared, single COPaper COM object that models a sheet
  33. of white drawing paper. Clients can use the methods of the COPaper object
  34. to draw on the paper surface using "ink" of specified color and
  35. width. This functionality is outwardly similar to the "scribble"
  36. tutorial samples in many versions of the Microsoft Visual C++®
  37. product. The drawing paper features of COPaper objects are exposed to
  38. DCOMDRAW clients by a custom ISharePaper interface. COPaper implements the
  39. ISharePaper interface. A clear architectural distinction is kept between
  40. client and server. No graphical user interface (GUI) is provided by the
  41. COPaper object. It relies on the DCOMDRAW client for all GUI behavior.
  42. COPaper encapsulates only the server-based capture and storage of the
  43. drawn ink data.
  44.  
  45. The ink data that is drawn on the COPaper surface can be stored in and
  46. loaded from compound files. The ISharePaper::Save and ISharePaper::Load
  47. method implementations in COPaper use structured storage to store the
  48. current data of the shared drawing in a compound file kept with
  49. DCDSERVE.EXE on the machine acting as the common server.
  50.  
  51. The DCOMDRAW sample creates and uses the connectable COPaper COM object
  52. that is provided as the CLSID_SharePaper component in the DCDSERVE server.
  53. The DCOMDRAW client creates a COPaper object and controls it using the
  54. methods of the ISharePaper interface. DCOMDRAW obtains drawing data from
  55. the user and displays that data in a window that it manages. DCOMDRAW uses
  56. COPaper's ISharePaper interface to save the drawing data in COPaper and to
  57. direct file-storage operations on this data.
  58.  
  59. COPaper only manages the drawing data; it performs no GUI actions.
  60. DCOMDRAW provides the GUI for the drawing application by encapsulating
  61. this functionality in a central CGuiPaper C++ object.
  62.  
  63. DCOMDRAW also implements the custom IPaperSink interface on a COPaperSink
  64. COM object and connects this interface to an appropriate connection point
  65. on the COPaper object in DCDSERVE. COPaper uses the connected IPaperSink
  66. interface to send notifications back to the COPaperSink in DCOMDRAW. The
  67. normal GUI repainting of COPaper's drawing data is done in DCOMDRAW using
  68. COPaper's connectable object technology. Thus in this sample, COM's
  69. connectable-object technology uses DCOM to function transparently across
  70. the network. In earlier samples such as STOCLIEN and STOSERVE, COM's
  71. connectable-object technology was shown operating only in-process.
  72.  
  73. The two ISharePaper and IPaperSink custom interfaces are declared in
  74. PAPINT.H, which is located in the common INC directory. PAPINT.H is
  75. automatically generated in the DCDMARSH sample. The GUIDs for the
  76. interfaces and objects are defined in PAPGUIDS.H located in that same
  77. directory.
  78.  
  79. This lesson focuses primarily on how to take care of DCOM process security
  80. on the client side and how to load a remote object using DCOM. Using
  81. CoInitializeSecurity to set process security is covered.
  82. CoCreateInstanceEx using the MULTI_QI structure is covered.
  83.  
  84. Because client and server run in separate processes--usually on different
  85. computers--both DCDSERVE and DCOMDRAW rely on standard marshaling for the
  86. ISharePaper and IPaperSink custom interfaces. The DCDMARSH sample provides
  87. this support, so you must build (or otherwise register) DCDMARSH.DLL on
  88. both machines prior to building and running DCDSERVE and DCOMDRAW across
  89. machines.
  90.  
  91. To set a DCOMDRAW client on one machine to control the common DCDSERVE
  92. server on another, both machines must have DCOM (Distributed COM)
  93. installed. DCOM is included in Windows NT 4.0 or above and in Windows 98.
  94. If a computer is running Windows 95, you must install the DCOM95 add on.
  95. DCOM95 can currently be obtained by download from Microsoft's world wide
  96. Web site at: http://www.microsoft.com/com/.
  97.  
  98. The multiple computers must be connected in a properly configured network.
  99. For details on setting up a network, see your Windows NT product
  100. documentation or the Windows NT Resource Kit. For more details on computer
  101. and network setup for running with DCOM, see the "Network and Setup
  102. Issues" section at the end of the REMCLIEN lesson. Note that the less
  103. restrictive security in Windows 95 and Windows 98 prevents the SCM under
  104. DCOM from automatically launching DCDSERVE on behalf of a remote DCOMDRAW
  105. client. You must manually pre-launch DCDSERVE on these operating systems
  106. if you attempt a remote load of DCDSERVE from a DCOMDRAW running on
  107. another machine. The DCDSERVE and DCOMDRAW lessons assume that you install
  108. DCDSERVE on a machine running Windows NT Server or Workstation.
  109.  
  110. For functional descriptions and a tutorial code tour of DCOMDRAW, see the
  111. Code Tour section in DCOMDRAW.HTM. For details on the external user
  112. operation of DCOMDRAW, see both the Usage and Operation sections in
  113. DCOMDRAW.HTM. To read DCOMDRAW.HTM, run TUTORIAL.EXE in the main tutorial
  114. directory and click the DCOMDRAW lesson in the table of lessons. You can
  115. do the same thing by locating the main tutorial directory in the Windows
  116. Explorer and double-clicking the DCOMDRAW.HTM file. For more details on
  117. how DCDSERVE works and exposes its services to DCOMDRAW, see DCDSERVE.HTM
  118. in the main tutorial directory. The makefile for DCDSERVE automatically
  119. registers that server in the registry of the host machine, so you must
  120. build DCDSERVE on the remote machine before attempting to run DCOMDRAW.
  121.  
  122. For general details on setting up your system to build and test Win32 code
  123. samples such as those in this COM Tutorial series, see TUTORIAL.HTM.
  124. The supplied MAKEFILE is Microsoft NMAKE-compatible. To create a debug
  125. build, issue the NMAKE command in the command-prompt window.
  126.  
  127.  
  128. Usage
  129. -----
  130.  
  131. DCOMDRAW is an application that you can execute directly from Windows or
  132. from the command-prompt window. No command-line parameters are recognized
  133. by DCOMDRAW. DCOMDRAW currently runs on the Windows 95 operating system
  134. with the DCOM95 update for Windows 95 installed. It will run on Windows 98
  135. which includes DCOM. It will also run under version 4 or later of Windows
  136. NT Workstation or Windows NT Server.
  137.  
  138.  
  139. FILES
  140. =====
  141.  
  142. Files          Description
  143.  
  144. DCOMDRAW.TXT   Short description of the sample.
  145. MAKEFILE       The generic Win32 makefile for building the code sample
  146.                application of this tutorial lesson.
  147. DCOMDRAW.H     The include file for the DCOMDRAW application. Contains
  148.                class declarations, function prototypes, and resource
  149.                identifiers.
  150. DCOMDRAW.CPP   The main implementation file for DCOMDRAW.EXE. Has WinMain
  151.                and CMainWindow implementation, as well as the main menu
  152.                dispatching.
  153. DCOMDRAW.RC    The application resource definition file.
  154. DCOMDRAW.ICO   The application icon resource.
  155. PENCURT.CUR    Pen cursor for the Thin pen width.
  156. PENCURM.CUR    Pen cursor for the Medium pen width.
  157. PENCURF.CUR    Pen cursor for the Fat pen width.
  158. PENCURN.CUR    Pen cursor for when drawing is off (pen is not owned).
  159. GUIPAPER.H     The class declaration for the CGuiPaper C++ class.
  160. GUIPAPER.CPP   Implementation file for the CGuiPaper C++ class.
  161. SINK.H         The class declaration for the COPaperSink COM object class.
  162. SINK.CPP       Implementation file for the COPaperSink COM object class.
  163.