home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap18 / cosmo1.0 / cosmo.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  6KB  |  199 lines

  1. /*
  2.  * COSMO.H
  3.  *
  4.  * Definitions and function prototypes for the OLE Cosmo Server.
  5.  *
  6.  * Copyright(c) Microsoft Corp. 1992-1994 All Rights Reserved
  7.  * Win32 version, January 1994
  8.  */
  9.  
  10. #include "polyline.h"
  11.  
  12. //Resource identifiers.
  13. #define IDR_MENU            1
  14. #define IDR_ACCELERATORS    1
  15. #define IDD_ABOUT           1
  16.  
  17. //POLYLINE Window ID
  18. #define ID_POLYLINE         10
  19.  
  20.  
  21. //Menu command identifiers.
  22. #define IDM_FILENEW         100
  23. #define IDM_FILEOPEN        101
  24. #define IDM_FILESAVE        102
  25. #define IDM_FILESAVEAS      103
  26. #define IDM_FILEIMPORT      104
  27. #define IDM_FILEEXIT        110
  28.  
  29. #define IDM_EDITUNDO        200
  30. #define IDM_EDITCUT         201
  31. #define IDM_EDITCOPY        202
  32. #define IDM_EDITPASTE       203
  33.  
  34. #define IDM_HELPABOUT       300
  35.  
  36.  
  37. //File-related string lengths.
  38. #define CCHPATHMAX          256
  39. #define CCHFILENAMEMAX      15
  40.  
  41.  
  42.  
  43. /*
  44.  * CSTRINGS is number of strings to load from the stringtable.
  45.  * CCHSTRINGMAX is the maximum length that any string is allowed.
  46.  *
  47.  * What will happen is that CSTRINGS*CCHSTRINGMAX is allocated to begin
  48.  * with and the stringtable is loaded into that space, Only using what's
  49.  * required for each string.  After that, the space is reallocated to
  50.  * be as small as possible.
  51.  */
  52.  
  53. #define CSTRINGS            30
  54. #define CCHSTRINGMAX        80
  55.  
  56.  
  57.  
  58. //String ID values.  Keep in SEQUENTIAL order and use 0-n
  59. #define IDS_CAPTION         0
  60. #define IDS_CLASSCOSMO      1
  61. #define IDS_CLASSPOLYLINE   2
  62. #define IDS_FILEDIRTY       3
  63. #define IDS_DEFEXT          4
  64. #define IDS_FILEOPENFILTER  5
  65. #define IDS_FILEOPEN        6
  66. #define IDS_FILESAVEAS      7
  67. #define IDS_FILEIMPORT      8
  68. #define IDS_FULLNAME        9
  69. #define IDS_FIGURE          10
  70. #define IDS_DOTEXT          11
  71. #define IDS_MODULE          12
  72. #define IDS_UNTITLED        13
  73. #define IDS_EMPTY           14
  74.  
  75. #define IDS_VERBEDIT        15
  76. #define IDS_UPDATE          16
  77. #define IDS_SAVE            17
  78. #define IDS_SAVEAS          18
  79. #define IDS_SAVECOPYAS      19
  80. #define IDS_EXIT            20
  81. #define IDS_EXITANDRETURN   21
  82. #define IDS_EMBEDDING       22
  83. #define IDS_NATIVE          23
  84. #define IDS_DATAFORMATS     24
  85. #define IDS_STDFILEEDITING  25
  86. #define IDS_OWNERLINK       26
  87. #define IDS_OBJECTLINK      27
  88.  
  89. #define IDS_CLOSEALERT1     28
  90. #define IDS_CLOSEALERT2     29
  91.  
  92.  
  93.  
  94.  
  95. /*
  96.  * Structure holding the "global" variables.  Creating a structure with
  97.  * has several advantages over separately declaring each field as a
  98.  * global:
  99.  *  1.  Keep source files clean.
  100.  *  2.  Eliminates need for many "extern" declarations.
  101.  *  3.  A single pointer to this structure can be passed throughout
  102.  *      the application, hiding the fact that it's global.
  103.  *  4.  Allows the variables to be allocated dynamically or from
  104.  *      different memory than the application's DS.
  105.  *  5.  Any reference to these variables will have a pointer or
  106.  *      structure dereference, which points to where the variable
  107.  *      actually is defined.  Separate globals are not distinguishable
  108.  *      from locals, making code harder to read.
  109.  *
  110.  * Note that fNoDirty is used from OLEOBJ.C in the ObjShow method
  111.  * to prevent setting fDirty when the window is sized from ObjShow.
  112.  */
  113.  
  114. typedef struct
  115.     {
  116.     HWND        hWnd;               //Top-level application window.
  117.     HWND        hWndPolyline;       //Editor window.
  118.     HINSTANCE   hInst;              //Application instance handle.
  119.     LPSTR       pszCmdLine;         //Command line passed to WinMain.
  120.     UINT        nCmdShow;           //Initial ShowWindow command.
  121.     HLOCAL      hStringMem;         //Stringtable memory.
  122.     UINT        cfCosmo;            //Private clipboard format.
  123.     BOOL        fDirty;             //Is file dirty?
  124.     BOOL        fNoDirty;           //If TRUE, don't touch dirty flag.
  125.     BOOL        fOpenFile;          //FALSE if File/New used until saved.
  126.     char        szFile[CCHPATHMAX]; //Filename for Save command.
  127.  
  128.     BOOL        fOLE;               //Indicates if we are linked/embedded.
  129.     } GLOBALS;
  130.  
  131. typedef GLOBALS FAR * LPGLOBALS;
  132.  
  133. //External:
  134. extern char NEAR *rgpsz[CSTRINGS];
  135. extern LPGLOBALS pGlob;
  136.  
  137.  
  138. //Versioning.
  139. #define VERSIONMAJOR        1
  140. #define VERSIONMINOR        0
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. /*
  149.  * Function prototypes, organized by source file.  Any small definition
  150.  * required by only one source file is also included here under the
  151.  * same heading.
  152.  */
  153.  
  154. //CLIP.C
  155. BOOL      WINAPI FEditCut(LPGLOBALS);
  156. BOOL      WINAPI FEditCopy(LPGLOBALS, BOOL);
  157. BOOL      WINAPI FEditPaste(LPGLOBALS);
  158. HGLOBAL   WINAPI HGetPolyline(HWND);
  159. HGLOBAL   WINAPI HGetMetafilePict(HWND);
  160. HGLOBAL   WINAPI HGetBitmap(HWND);
  161.  
  162.  
  163. //COMMDLG.C
  164. BOOL     WINAPI FSaveOpenDialog(HWND, HINSTANCE, LPSTR, LPSTR, LPSTR, LPSTR, BOOL);
  165.  
  166. //EXIT.C
  167. BOOL     WINAPI FApplicationExit(LPGLOBALS);
  168.  
  169. //FILE.C
  170. BOOL     WINAPI FDirtySet(BOOL);
  171. BOOL     WINAPI FCleanVerify(LPGLOBALS);
  172. BOOL     WINAPI FFileNew(LPGLOBALS);
  173. BOOL     WINAPI FFileOpen(LPGLOBALS, BOOL);
  174. BOOL     WINAPI FFileSave(LPGLOBALS);
  175. BOOL     WINAPI FFileSaveAs(LPGLOBALS);
  176. BOOL     WINAPI FFileExit(LPGLOBALS);
  177.  
  178. //FILEIO.C
  179. BOOL     WINAPI FCosFileRead(LPGLOBALS, LPSTR, LPPOLYLINE);
  180. BOOL     WINAPI FCosFileWrite(LPGLOBALS, LPSTR, LPPOLYLINE);
  181.  
  182.  
  183. //INIT.C
  184. BOOL     WINAPI FApplicationInit(LPGLOBALS, HINSTANCE);
  185. BOOL     WINAPI FClassRegister(LPGLOBALS, HINSTANCE);
  186. BOOL     WINAPI FFileInit(LPGLOBALS);
  187. HLOCAL   WINAPI HLoadAppStrings(LPGLOBALS);
  188. HLOCAL   WINAPI HListParse(LPSTR);
  189. LPSTR    PASCAL PszWhiteSpaceScan(LPSTR, BOOL);
  190.  
  191. //MISC.C
  192. void     WINAPI WindowTitleSet(HWND, LPSTR);
  193. void     WINAPI RectConvertToHiMetric(HWND, LPRECT);
  194. void     WINAPI RectConvertToDevice(HWND, LPRECT);
  195.  
  196. //COSMO.C
  197. LRESULT  WINAPI CosmoWndProc(HWND, UINT, WPARAM, LPARAM);
  198. BOOL     WINAPI AboutProc(HWND, UINT, WPARAM, LPARAM);
  199.