📄 cosmo.h
字号:
/*
* COSMO.H
* Cosmo Chapter 14
*
* Single include file that pulls in everything needed for other
* source files in the Cosmo application.
*
* Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Microsoft
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _COSMO_H_
#define _COSMO_H_
#define INC_CLASSLIB
//CHAPTER14MOD
#define INC_AUTOMATION
#define GUIDS_FROM_TYPELIB
#define CHAPTER14
#include <memory.h>
//End CHAPTER14MOD
#include <inole.h>
#include "resource.h"
//CHAPTER14MOD
//Get the Automation interfaces
#include "icosmo.h"
//End CHAPTER14MOD
//Get the editor window information.
#include "polyline.h"
//CHAPTER14MOD
/*
* Forward reference automation object classes for our frame
* and document classes which then contain them.
*/
class CAutoApp;
typedef CAutoApp *PCAutoApp;
class CClassFactory;
typedef CClassFactory *PCClassFactory;
class CAutoFigures;
typedef CAutoFigures *PCAutoFigures;
class CAutoFigure;
typedef CAutoFigure *PCAutoFigure;
//End CHAPTER14MOD
//COSMO.CPP: Frame object that creates a main window
class CCosmoFrame : public CFrame
{
//CHAPTER14MOD
friend CClassFactory;
friend CAutoApp;
friend CAutoFigures;
//End CHAPTER14MOD
private:
HBITMAP m_hBmpLines[5]; //Menu item bitmaps
UINT m_uIDCurLine; //Current line selection
BOOL m_fInitialized; //Did OleInitalize work?
LPCLASSFACTORY m_pIClassDataTran; //For locking
//CHAPTER14MOD
BOOL m_fEmbedding; //-Embedding flag?
BOOL m_fAutomation; //-Automation flag?
PCAutoApp m_pAutoApp; //Implements ICosmoApplication
DWORD m_dwActiveApp; //From RegisterActiveObject
PCClassFactory m_pIClassFactoryApp;
DWORD m_dwRegCOApp;
PCClassFactory m_pIClassFactoryFig;
DWORD m_dwRegCOFig;
//End CHAPTER14MOD
protected:
//Overridable for creating a CClient for this frame
virtual PCClient CreateCClient(void);
virtual BOOL RegisterAllClasses(void);
virtual BOOL PreShowInit(void);
virtual UINT CreateToolbar(void);
virtual LRESULT OnCommand(HWND, WPARAM, LPARAM);
virtual void OnDocumentDataChange(PCDocument);
virtual void OnDocumentActivate(PCDocument);
//New for this class
virtual void CreateLineMenu(void);
public:
CCosmoFrame(HINSTANCE, HINSTANCE, LPSTR, int);
virtual ~CCosmoFrame(void);
//Overrides
virtual BOOL Init(PFRAMEINIT);
virtual void UpdateMenus(HMENU, UINT);
virtual void UpdateToolbar(void);
//New for this class
virtual void CheckLineSelection(UINT);
//CHAPTER14MOD
PCAutoApp AutoApp(void);
//End CHAPTER14MOD
};
typedef CCosmoFrame *PCCosmoFrame;
//CLIENT.CPP
/*
* The only reason we have a derived class here is to override
* CreateCDocument so we can create our own type as well as
* overriding NewDocument to perform one other piece of work once
* the document's been created.
*/
class CCosmoClient : public CClient
{
//CHAPTER14MOD
friend class CAutoFigures;
//End CHAPTER14MOD
//CHAPTER14MOD
protected:
PCAutoFigures m_pAutoFigures; //Collection object
//End CHAPTER14MOD
protected:
//Overridable for creating a new CDocument
virtual PCDocument CreateCDocument(void);
public:
CCosmoClient(HINSTANCE, PCFrame);
virtual ~CCosmoClient(void);
virtual BOOL Init(HMENU, LPRECT);
virtual PCDocument NewDocument(BOOL);
//CHAPTER14MOD
PCAutoFigures AutoFigures(void);
//End CHAPTER14MOD
};
typedef CCosmoClient *PCCosmoClient;
//DOCUMENT.CPP
//Constant ID for the window polyline that lives in a document
#define ID_POLYLINE 10
class CCosmoDoc : public CDocument
{
friend class CPolylineAdviseSink;
//CHAPTER14MOD
friend class CAutoFigure;
//End CHAPTER14MOD
protected:
UINT m_uPrevSize; //Last WM_SIZE wParam
LONG m_lVer; //Loaded Polyline ver
PCPolyline m_pPL; //Polyline window here
PCPolylineAdviseSink m_pPLAdv; //Advises from Polyline
//CHAPTER14MOD
PCAutoFigure m_pAutoFig; //ICosmoFigure
DWORD m_dwActiveFig; //From RegisterActiveObject
//End CHAPTER14MOD
protected:
virtual BOOL FMessageHook(HWND, UINT, WPARAM, LPARAM
, LRESULT *);
virtual BOOL FQueryPasteFromData(LPDATAOBJECT);
virtual BOOL PasteFromData(LPDATAOBJECT);
public:
CCosmoDoc(HINSTANCE, PCFrame, PCDocumentAdviseSink);
virtual ~CCosmoDoc(void);
virtual BOOL Init(PDOCUMENTINIT);
virtual void Clear(void);
virtual UINT Load(BOOL, LPTSTR);
virtual UINT Save(UINT, LPTSTR);
virtual void Undo(void);
virtual BOOL Clip(HWND, BOOL);
virtual HGLOBAL RenderFormat(UINT);
virtual BOOL FQueryPaste(void);
virtual BOOL Paste(HWND);
virtual COLORREF ColorSet(UINT, COLORREF);
virtual COLORREF ColorGet(UINT);
virtual UINT LineStyleSet(UINT);
virtual UINT LineStyleGet(void);
//CHAPTER14MOD
PCAutoFigure AutoFigure(void);
//End CHAPTER14MOD
};
typedef CCosmoDoc *PCCosmoDoc;
//These color indices wrap the polyline definitions
#define DOCCOLOR_BACKGROUND POLYLINECOLOR_BACKGROUND
#define DOCCOLOR_LINE POLYLINECOLOR_LINE
//CHAPTER14MOD
//These are global for simplification of object implementation.
extern ULONG g_cObj;
extern ULONG g_cLock;
extern HWND g_hWnd;
//Function for the object to notify on destruction.
void ObjectDestroyed(void);
//ICLASSF.CPP: The generic class factory for our automation objects
class CClassFactory : public IClassFactory
{
protected:
ULONG m_cRef;
PCCosmoFrame m_pFR;
CLSID m_clsID;
BOOL m_fCreated; //Created one object yet?
public:
CClassFactory(PCCosmoFrame, REFCLSID);
~CClassFactory(void);
//IUnknown members
STDMETHODIMP QueryInterface(REFIID, PPVOID);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IClassFactory members
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID
, PPVOID);
STDMETHODIMP LockServer(BOOL);
};
typedef CClassFactory *PCClassFactory;
//AUTOBASE.CPP
class CImpIDispatch;
typedef CImpIDispatch *PCImpIDispatch;
class CImpIExtConn;
typedef class CImpIExtConn *PCImpIExtConn;
/*
* CAutoBase is a base class for the other automation objects
* in this application. It centralizes the implementation of
* IDispatch as well as the loading of type information. Since
* it implements an IDispatch that calls ITypeInfo directly, this
* is structured to handle multiple languages although this
* sample only uses one.
*
* The pure virtual VTableInterface makes this an abstract
* base class. That one function must be overridden to supply
* the right interface pointer to IDispatch::Invoke.
*/
class CAutoBase
{
friend CImpIDispatch;
public:
ULONG m_cRef; //Public for debug checks
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -