|
|
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: #include "minsvrMI.h"
12:
13: // Main application parts and OLE server parts
14: // see 'mainwnd.cpp' for main window parts and item UI
15:
16: /////////////////////////////////////////////////////////////////////////////
17: // single object for the app
18: CMiApp app;
19:
20: CMiApp::CMiApp()
21: : CWinApp(SERVER_NAME), COleServer(TRUE)
22: {
23: m_data = "sample data (MI version)";
24: }
25:
26: /////////////////////////////////////////////////////////////////////////////
27: // Main app processing
28:
29: BOOL CMiApp::InitInstance()
30: {
31: BOOL bEmbedded = FALSE;
32:
33: // check if run with /Embedding
34: LPCSTR lpsz = m_lpCmdLine;
35:
36: while (*lpsz == ' ')
37: lpsz++;
38: if ((*lpsz == '-' || *lpsz == '/') &&
39: _fstrncmp("Embedding", lpsz+1, 9) == 0)
40: {
41: lpsz += 10;
42: bEmbedded = TRUE;
43: }
44:
45: if (!bEmbedded)
46: {
47: // register as a server
48: if (AfxOleRegisterServerName(SERVER_NAME, SERVER_LOCAL_NAME))
49: {
50: MessageBox("Server Registered,"
51: " please run from within host application.",
52: AfxGetAppName());
53: }
54: else
55: {
56: MessageBox("Server failed to register, try using REGEDIT.",
57: AfxGetAppName());
58: }
59: return FALSE;
60: }
61:
62: // Server Init
63: if (!COleServer::Register(SERVER_NAME, TRUE)) // multi-instance server
64: {
65: MessageBox("Could not register server", AfxGetAppName(), MB_OK);
66: return FALSE;
67: }
68:
69:
70: // MiApp ignores rest of command line - normally use this as a
71: // document file name
72:
73: // Window init
74: CRect rect(0, 200, 200, 400);
75: Create(NULL, SERVER_LOCAL_NAME, WS_OVERLAPPEDWINDOW,
76: rect, NULL, "MainMenu");
77: ShowWindow(m_nCmdShow);
78: UpdateWindow();
79: m_pMainWnd = this; // we are a main window !
80:
81: return TRUE;
82: }
83:
84: /////////////////////////////////////////////////////////////////////////////
85: // OLE Server functionality
86:
87: COleServerDoc*
88: CMiApp::OnOpenDoc(LPCSTR)
89: {
90: return this;
91: }
92:
93: COleServerDoc*
94: CMiApp::OnCreateDoc(LPCSTR, LPCSTR)
95: {
96: return this;
97: }
98:
99: COleServerDoc*
100: CMiApp::OnEditDoc(LPCSTR, LPCSTR)
101: {
102: return this;
103: }
104:
105: /////////////////////////////////////////////////////////////////////////////
106: // OLE Server Doc functionality
107:
108: COleServerItem* CMiApp::OnGetDocument()
109: {
110: return this;
111: }
112:
113: COleServerItem* CMiApp::OnGetItem(LPCSTR)
114: {
115: return this;
116: }
117:
118: COleServerItem* CMiApp::GetNextItem(POSITION& rPosition)
119: {
120: if (rPosition != NULL)
121: return NULL;
122: rPosition = (POSITION) 1;
123: return this;
124: }
125:
126: /////////////////////////////////////////////////////////////////////////////
127: // OLE Server Item functionality
128:
129: void
130: CMiApp::Serialize(CArchive& ar)
131: {
132: // Customize this to store real data
133: if (ar.IsStoring())
134: {
135: ar << m_data;
136: }
137: else
138: {
139: ar >> m_data;
140: }
141: }
142:
143:
144: BOOL
145: CMiApp::OnGetTextData(CString& rStringReturn)
146: {
147: rStringReturn = m_data;
148: return TRUE;
149: }
150:
151: /////////////////////////////////////////////////////////////////////////////
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.