home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / SAMPLES / SRVRDEMO / SRVRDEMO.H_ / SRVRDEMO.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  9.8 KB  |  289 lines

  1. /*
  2.   OLE SERVER DEMO
  3.   SrvrDemo.h
  4.  
  5.   This file contains typedefs, defines, global variable declarations, and
  6.   function prototypes.
  7.  
  8.   (c) Copyright Microsoft Corp. 1990 - 1992 All Rights Reserved
  9. */
  10.  
  11.  
  12. /*
  13.    Explanation of Function Comments.
  14.  
  15.    Every function has a comment preceding it which gives the following
  16.    information:
  17.  
  18.    1) Function name.
  19.    2) A description of what the function does.
  20.    3) A list of parameters, each with its type and a short description.
  21.    4) A list of return values, each with an explanation of the condition that
  22.       will cause the function to return that value.
  23.    5) A customization section giving tips on how to customize this function
  24.       for your OLE application.
  25.       If the customization section says "None" then you may find the function
  26.       usable as is.
  27.       If the customization section says "Re-implement" then the function
  28.       should still serve the same purpose and do what is indicated in the
  29.       function comment, but will probably need to be re-implemented for
  30.       your particular application.  Any Server Demo code relating to OLE
  31.       will be useful as a guide in your re-implementation.
  32.       If the customization section says "Server Demo specific" then the
  33.       function will probably have no counterpart in your application.
  34. */
  35. #include "resource.h"
  36.  
  37.  
  38. #define OBJECT_WIDTH        120
  39. #define OBJECT_HEIGHT       60
  40.  
  41. // number HIMETRIC units per inch
  42. #define  HIMETRIC_PER_INCH  2540
  43.  
  44. /* Types */
  45.  
  46. // Document type
  47.  
  48. typedef enum
  49. {
  50.     doctypeNew,      // The document is untitled.
  51.     doctypeFromFile, // The document exists in a file and may be linked.
  52.     doctypeEmbedded, // The document is an embedded document.
  53. } DOCTYPE;
  54.  
  55.  
  56. // Device context type, passed to DrawObj.
  57.  
  58. typedef enum
  59. {
  60.    dctypeScreen,
  61.    dctypeBitmap,
  62.    dctypeMetafile
  63. } DCTYPE ;
  64.  
  65.  
  66. // Version
  67.  
  68. typedef int VERSION;
  69.  
  70.  
  71. // Verb
  72.  
  73. typedef enum
  74. {
  75.    verbPlay = OLEVERB_PRIMARY,
  76.    verbEdit
  77. } VERB;
  78.  
  79.  
  80. // Server structure
  81.  
  82. typedef struct
  83. {
  84.     OLESERVER     olesrvr;        // This must be the first field so that
  85.                                   //   an LPOLESERVER can be cast to a SRVR*.
  86.     LHSERVER      lhsrvr;         // Registration handle
  87. } SRVR ;
  88.  
  89.  
  90. // How many objects (distinct numbers) will we allow?
  91. #define cfObjNums 20
  92.  
  93. // How many distinct clients can be associated with the object?
  94. #define clpoleclient 20
  95.  
  96.  
  97. // Document structure
  98.  
  99. typedef struct
  100. {
  101.     OLESERVERDOC oledoc;      // This must be the first field so that an
  102.                               //   LPOLESERVERDOC can be cast to an DOC*.
  103.     LHSERVERDOC  lhdoc;       // Registration handle
  104.     DOCTYPE      doctype;     // Document type
  105.     ATOM         aName;       // Document name
  106.     HPALETTE     hpal;        // Handle to a logical color palette
  107.     BYTE         rgfObjNums[cfObjNums+1]; // What object numbers have been used
  108. } DOC, FAR *DOCPTR ;
  109.  
  110.  
  111. // Native data structure
  112.  
  113. typedef struct
  114. {
  115.     int         idmColor;
  116.     int         nWidth;
  117.     int         nHeight;
  118.     int         nX;
  119.     int         nY;
  120.     int         nHiMetricWidth;  // Used by an object handler.  These two fields
  121.     int         nHiMetricHeight; // always correspond to nWidth and nHeight.
  122.     VERSION     version;
  123.     char        szName[10];      // "Object nn"
  124. } NATIVE, FAR *LPNATIVE;
  125.  
  126.  
  127. // Object structure
  128.  
  129. /* Ordinarily, an OBJ structure would not contain native data.  Rather, it
  130.    would contain a pointer (or some other reference) to the native data.
  131.    This method would allow multiple objects containing the same native data.
  132.    Each OBJ structure would be created on the fly when some portion of the
  133.    document was to be made into an object.  Each OBJ structure would have
  134.    only one LPOLECLIENT, which would be passed in to DocGetObject.
  135. */
  136.  
  137. typedef struct
  138. {
  139.     OLEOBJECT   oleobject;   // This must be the first field so that an
  140.                              //   LPOLEOBJECT can be cast to a LPOBJ.
  141.     HANDLE      hObj;        // A circular handle to this structure,
  142.                              //   used to delete this structure.
  143.     LPOLECLIENT lpoleclient[clpoleclient];
  144.                              // Clients associated with the object.
  145.                              //   The array is NULL terminated.
  146.     HWND        hwnd;        // The object's own window
  147.     ATOM        aName;       // Unique identifier for each object within a doc
  148.     HPALETTE    hpal;        // Logical palette to use in drawing object
  149.     NATIVE      native;      // Object data in native format
  150. } OBJ, FAR *LPOBJ ;
  151.  
  152.  
  153.  
  154. /* Defines */
  155.  
  156. // The name of the application, used in message boxes and title bars.
  157. #define szAppName        "Server Demo"
  158.  
  159. // THe class name in the registration database.
  160. #define szClassName      "ServerDemo"
  161.  
  162. // Used to check for "-Embedding" on command line.
  163. #define szEmbeddingFlag  "Embedding"
  164.  
  165. // Maximum length of a fully-qualified pathname.
  166. #define cchFilenameMax   256
  167.  
  168. // Maximum number of HBRUSHes.
  169. #define chbrMax          9
  170.  
  171. // Number of extra bytes in the window structure for an object
  172. #define cbWindExtra 4
  173.  
  174. // Offset (in the extra space) of the pointer to the object
  175. #define ibLpobj          0
  176.  
  177.  
  178.  
  179. /* Global variable declarations.  (See SrvrDemo.c for descriptions.) */
  180.  
  181. extern HANDLE           hInst;
  182. extern HWND             hwndMain;
  183. extern SRVR             srvrMain;
  184. extern DOC              docMain;
  185. extern BOOL             fDocChanged;
  186. extern BOOL             fEmbedding;
  187. extern BOOL             fRevokeSrvrOnSrvrRelease;
  188. extern BOOL             fWaitingForDocRelease;
  189. extern BOOL             fWaitingForSrvrRelease;
  190. extern BOOL             fUnblock;
  191. extern char             szClient[];
  192. extern char             szClientDoc[];
  193. extern HBRUSH           hbrColor[chbrMax];
  194. extern VERSION          version;
  195. extern OLECLIPFORMAT    cfObjectLink;
  196. extern OLECLIPFORMAT    cfOwnerLink;
  197. extern OLECLIPFORMAT    cfNative;
  198. extern OLESERVERDOCVTBL docvtbl;
  199. extern OLEOBJECTVTBL    objvtbl;
  200. extern OLESERVERVTBL    srvrvtbl;
  201.  
  202.  
  203.  
  204. /* Function Prototypes */
  205.  
  206. // Various functions
  207.  
  208. BOOL  CreateDocFromFile (LPSTR lpszDoc, LHSERVERDOC lhdoc, DOCTYPE doctype);
  209. BOOL  CreateNewDoc (LONG lhdoc, LPSTR lpszDoc, DOCTYPE doctype);
  210. LPOBJ CreateNewObj (BOOL fDoc_Changed);
  211. void  CutOrCopyObj (BOOL fOpIsCopy);
  212. void  DestroyDoc (void);
  213. void  DestroyObj (HWND hwnd);
  214. void  DeviceToHiMetric (HWND hwnd, LPPOINT lppt);
  215. void  EmbeddingModeOff (void) ;
  216. void  EmbeddingModeOn (void);
  217. void  UpdateFileMenu (int);
  218. void  ErrorBox (char *jwf);
  219. void  FreeVTbls (void);
  220. BOOL  GetFileOpenFilename (LPSTR lpszFilename);
  221. BOOL  GetFileSaveFilename (LPSTR lpszFilename);
  222. void  HiMetricToDevice (HWND hwnd, LPPOINT lppt);
  223. LPOBJ HwndToLpobj (HWND hwndObj);
  224. BOOL  InitServer (HWND hwnd, HANDLE hInst);
  225. void  InitVTbls (void);
  226. BOOL  OpenDoc (void);
  227. void  PaintObj (HWND hwnd);
  228. OLESTATUS RevokeDoc (void);
  229. void  RevokeObj (LPOBJ lpobj);
  230. int   SaveChangesOption (BOOL *pfUpdateLater);
  231. BOOL  SaveDoc (void);
  232. BOOL  SaveDocAs (void);
  233. void  SavedServerDoc (void);
  234. LPOBJ SelectedObject (void);
  235. HWND  SelectedObjectWindow (void);
  236. void  SendDocMsg (WORD wMessage );
  237. void  SendObjMsg (LPOBJ lpobj, WORD wMessage);
  238. void  SetTitle (LPSTR lpszDoc, BOOL bEmbedded);
  239. void  SetHiMetricFields (LPOBJ lpobj);
  240. void  SizeClientArea (HWND hwndMain, RECT rectReq, BOOL fFrame);
  241. void  SizeObj (HWND hwnd, RECT rect, BOOL fMove);
  242. OLESTATUS StartRevokingServer (void);
  243. void  Wait (BOOL *pf);
  244. LPSTR Abbrev (LPSTR lpsz);
  245. BOOL FAR PASCAL __export fnFailedUpdate (HWND, WORD, WORD, DWORD);
  246. int PASCAL WinMain
  247.    (HANDLE  hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
  248.  
  249. // Window handlers
  250.  
  251. BOOL FAR PASCAL __export About       (HWND, unsigned, WORD, LONG);
  252. long FAR PASCAL __export MainWndProc (HWND, UINT, WPARAM, LPARAM);
  253. long FAR PASCAL __export ObjWndProc  (HWND, UINT, WPARAM, LPARAM);
  254.  
  255.  
  256. // Server methods
  257.  
  258. OLESTATUS FAR PASCAL __export SrvrCreate (LPOLESERVER, LHSERVERDOC, LPSTR, LPSTR, LPOLESERVERDOC FAR *);
  259. OLESTATUS FAR PASCAL __export SrvrCreateFromTemplate (LPOLESERVER, LHSERVERDOC, LPSTR, LPSTR, LPSTR, LPOLESERVERDOC FAR *);
  260. OLESTATUS FAR PASCAL __export SrvrEdit (LPOLESERVER, LHSERVERDOC, LPSTR, LPSTR, LPOLESERVERDOC FAR * );
  261. OLESTATUS FAR PASCAL __export SrvrExecute (LPOLESERVER, HANDLE);
  262. OLESTATUS FAR PASCAL __export SrvrExit (LPOLESERVER);
  263. OLESTATUS FAR PASCAL __export SrvrOpen (LPOLESERVER, LHSERVERDOC, LPSTR, LPOLESERVERDOC FAR *);
  264. OLESTATUS FAR PASCAL __export SrvrRelease (LPOLESERVER);
  265.  
  266. // Document methods
  267.  
  268. OLESTATUS FAR PASCAL __export DocClose (LPOLESERVERDOC);
  269. OLESTATUS FAR PASCAL __export DocExecute (LPOLESERVERDOC, HANDLE);
  270. OLESTATUS FAR PASCAL __export DocGetObject (LPOLESERVERDOC, LPSTR, LPOLEOBJECT FAR *, LPOLECLIENT);
  271. OLESTATUS FAR PASCAL __export DocRelease (LPOLESERVERDOC);
  272. OLESTATUS FAR PASCAL __export DocSave (LPOLESERVERDOC);
  273. OLESTATUS FAR PASCAL __export DocSetColorScheme (LPOLESERVERDOC, LPLOGPALETTE);
  274. OLESTATUS FAR PASCAL __export DocSetDocDimensions (LPOLESERVERDOC, LPRECT);
  275. OLESTATUS FAR PASCAL __export DocSetHostNames (LPOLESERVERDOC, LPSTR, LPSTR);
  276.  
  277. // Object methods
  278.  
  279. OLESTATUS FAR PASCAL __export ObjDoVerb (LPOLEOBJECT, WORD, BOOL, BOOL);
  280. OLESTATUS FAR PASCAL __export ObjGetData (LPOLEOBJECT, OLECLIPFORMAT, LPHANDLE);
  281. LPVOID    FAR PASCAL __export ObjQueryProtocol (LPOLEOBJECT, LPSTR);
  282. OLESTATUS FAR PASCAL __export ObjRelease (LPOLEOBJECT);
  283. OLESTATUS FAR PASCAL __export ObjSetBounds (LPOLEOBJECT, LPRECT);
  284. OLESTATUS FAR PASCAL __export ObjSetColorScheme (LPOLEOBJECT, LPLOGPALETTE);
  285. OLESTATUS FAR PASCAL __export ObjSetData (LPOLEOBJECT, OLECLIPFORMAT, HANDLE);
  286. OLESTATUS FAR PASCAL __export ObjSetTargetDevice (LPOLEOBJECT, HANDLE);
  287. OLESTATUS FAR PASCAL __export ObjShow (LPOLEOBJECT, BOOL);
  288. OLECLIPFORMAT FAR PASCAL __export ObjEnumFormats (LPOLEOBJECT, OLECLIPFORMAT);
  289.