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