Annotation of mstools/samples/ole/srvrdemo/srvrdemo.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.