|
|
1.1 root 1: // This is a part of the Microsoft Foundation Classes C++ library.
2: // Copyright (C) 1992 Microsoft Corporation
3: // All rights reserved.
4: //
5: // This source code is only intended as a supplement to the
6: // Microsoft Foundation Classes Reference and Microsoft
7: // QuickHelp documentation provided with the library.
8: // See these sources for detailed information regarding the
9: // Microsoft Foundation Classes product.
10:
11:
12: // Minsvr.cpp : minimal OLE Server
13:
14: /////////////////////////////////////////////////////////////////////////////
15:
16: #include <afxole.h>
17: #include "resource.h"
18:
19: /////////////////////////////////////////////////////////////////////////////
20: // CMinItem : mini server item
21:
22: class CMinDoc;
23:
24: class CMinItem : public COleServerItem
25: {
26: // Constructors
27: public:
28: CMinItem();
29:
30: // Attributes
31: CMinDoc* GetDocument() const // type cast helper
32: { return (CMinDoc*) COleServerItem::GetDocument(); }
33:
34: CString m_data; // example of item data
35:
36: // Operations
37: BOOL PromptChangeString(); // return TRUE if changed
38:
39: // Overridables
40: protected:
41: virtual OLESTATUS OnShow(BOOL bTakeFocus);
42: virtual BOOL OnDraw(CMetaFileDC* pDC);
43:
44: virtual void Serialize(CArchive& ar); // for native data
45: virtual BOOL OnGetTextData(CString& rStringReturn);
46: };
47:
48: /////////////////////////////////////////////////////////////////////////////
49: // CMinDoc : mini server document
50:
51: class CMinDoc : public COleServerDoc
52: {
53: // Attributes
54: public:
55: CMinItem m_item; // document contains one item
56:
57: // Overridables for OLE server
58: protected:
59: virtual COleServerItem* OnGetDocument();
60: virtual COleServerItem* OnGetItem(LPCSTR lpszObjname);
61: virtual COleServerItem* GetNextItem(POSITION& rPosition);
62: };
63:
64: /////////////////////////////////////////////////////////////////////////////
65: // CMinServer : mini server
66:
67: class CMainWnd;
68:
69: #define SERVER_NAME "MINSVR"
70: #define SERVER_LOCAL_NAME "Mini OLE Server"
71:
72: class CMinServer : public COleServer
73: {
74: public:
75: CMinServer(CMainWnd* pMainWnd);
76:
77: // Attributes
78: public:
79: CMinDoc m_doc; // single document server (multi-instance app)
80:
81: protected:
82: // Overridables for OLE Server requests
83: virtual COleServerDoc* OnOpenDoc(LPCSTR lpszDoc);
84: virtual COleServerDoc* OnCreateDoc(LPCSTR lpszClass, LPCSTR lpszDoc);
85: virtual COleServerDoc* OnEditDoc(LPCSTR lpszClass, LPCSTR lpszDoc);
86:
87: // Implementation
88: protected:
89: CMainWnd* m_pMainWnd;
90: };
91:
92: /////////////////////////////////////////////////////////////////////////////
93: // CMainWnd : the main window
94:
95: class CMainWnd : public CFrameWnd
96: {
97: // Construction
98: public:
99: CMainWnd();
100:
101: // Attributes
102: public:
103: CMinServer m_server; // (contains server (contains doc (contains item)))
104:
105: // Implementation
106: protected:
107: afx_msg void OnClose();
108:
109: // menu commands
110: afx_msg void OnUpdateClient();
111: afx_msg void OnChangeString();
112: afx_msg void OnAbout();
113:
114: DECLARE_MESSAGE_MAP()
115: };
116:
117: /////////////////////////////////////////////////////////////////////////////
118: // CMinApp : the application
119:
120: class CMinApp : public CWinApp
121: {
122: public:
123: // single server application
124: CMinApp() : CWinApp(SERVER_NAME)
125: { }
126:
127: // implementation
128: BOOL InitInstance();
129: int ExitInstance();
130: };
131:
132: /////////////////////////////////////////////////////////////////////////////
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.