// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and Microsoft
// WinHelp documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.


// Minsvr.cpp : minimal OLE Server

#include "resource.h"       // include resource IDs

/////////////////////////////////////////////////////////////////////////////
// CMinItem : mini server item

class CMinDoc;

class CMinItem : public COleServerItem
{
// Constructors
public:
	CMinItem(CMinDoc* pContainerDoc);

// Attributes
	CMinDoc*    GetDocument() const // type cast helper
					{ return (CMinDoc*) COleServerItem::GetDocument(); }

	CString m_data;     // example of item data

// Operations
	BOOL    PromptChangeString();       // return TRUE if changed

// Overridables
protected:
	virtual OLESTATUS   OnShow(BOOL bTakeFocus);
	virtual BOOL        OnDraw(CDC* pDC);

	virtual void        Serialize(CArchive& ar);        // for native data
	virtual BOOL        OnGetTextData(CString& rStringReturn);
};

/////////////////////////////////////////////////////////////////////////////
// CMinDoc : mini server document

class CMinDoc : public COleServerDoc
{
// Constructors
public:
	CMinDoc();

// Attributes
public:
	CMinItem m_item; // document contains one item

// Overridables for OLE server
protected:
	virtual COleServerItem* OnGetEmbeddedItem();
};

/////////////////////////////////////////////////////////////////////////////
// CMinServer : mini server

class CMainWnd;

#define SERVER_NAME         "MINSVR"
#define SERVER_LOCAL_NAME   "Mini OLE Server"

class CMinServer : public COleServer
{
public:
	CMinServer(CMainWnd* pMainWnd);

// Attributes
public:
	CMinDoc m_doc;      // single document server (multi-instance app)

protected:
// Overridables for OLE Server requests
	virtual COleServerDoc* OnOpenDoc(LPCSTR lpszDoc);
	virtual COleServerDoc* OnCreateDoc(LPCSTR lpszClass, LPCSTR lpszDoc);
	virtual COleServerDoc* OnEditDoc(LPCSTR lpszClass, LPCSTR lpszDoc);

// Implementation
protected:
	CMainWnd* m_pMainWnd;
};

/////////////////////////////////////////////////////////////////////////////
// CMainWnd : the main window

class CMainWnd : public CFrameWnd
{
// Construction
public:
	CMainWnd();

// Attributes
public:
	CMinServer m_server; // (contains server (contains doc (contains item)))

// Implementation
protected:

	//{{AFX_MSG(CMainWnd)
	afx_msg void OnClose();
	afx_msg void OnUpdateClient();
	afx_msg void OnChangeString();
	afx_msg void OnAbout();
	afx_msg void OnExit();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
// CMinApp : the application

class CMinApp : public CWinApp
{
public:
	// single server application
	CMinApp();

	// implementation
	BOOL InitInstance();
	int ExitInstance();
};

/////////////////////////////////////////////////////////////////////////////
