⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cosmo.h

📁 英文版的 想要的话可以下载了 为大家服务
💻 H
📖 第 1 页 / 共 2 页
字号:

    protected:
        PFNDESTROYED    m_pfnDestroy;
        HINSTANCE       m_hInst;

        /*
         * This union will have some pointer in it.  The CAutoBase
         * implementation stores m_pObj.  Derived classes may
         * reference that pointer as a frame, client, or
         * document pointer.
         */
        union
            {
            void           *m_pObj;
            PCCosmoFrame    m_pFR;
            PCCosmoClient   m_pCL;
            PCCosmoDoc      m_pDoc;
            };

        IID             m_iid;
        IID             m_diid;

        PCImpIDispatch  m_pImpIDispatch;    //Our IDispatch
        PCImpIExtConn   m_pImpIExtConn;     //For app or doc

    protected:
        virtual void *VTableInterface(void)=0;

    public:
        CAutoBase(void *, HINSTANCE, REFIID, REFIID
            , PFNDESTROYED);
        virtual CAutoBase::~CAutoBase(void);

        virtual BOOL    Init(BOOL);
    };

typedef CAutoBase *PCAutoBase;


/*
 * CImpIDispatch is the contained object inside CAutoBase that
 * provides the entry points for IDispatch.  We could use
 * CreateStdDispatch for this, but this sample is structured
 * for multilingual support so we use our own IDispatch.
 */

class CImpIDispatch : public IDispatch
    {
    public:
        ULONG           m_cRef;             //For debugging
        ITypeInfo      *m_pITypeInfo;       //Loaded

    private:
        PCAutoBase      m_pObj;
        LPUNKNOWN       m_pUnkOuter;

    public:
        CImpIDispatch(PCAutoBase, LPUNKNOWN);
        ~CImpIDispatch(void);

        //IUnknown members that delegate to m_pUnkOuter.
        STDMETHODIMP         QueryInterface(REFIID, PPVOID);
        STDMETHODIMP_(ULONG) AddRef(void);
        STDMETHODIMP_(ULONG) Release(void);

        //IDispatch members
        STDMETHODIMP GetTypeInfoCount(UINT *);
        STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
        STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID
            , DISPID *);
        STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD
            , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
    };



/*
 * Implementation of generic IExternalConnection for both the
 * application and document objects which will call the app or
 * document object's Release when the last external connection
 * disappears.
 */

class CImpIExtConn : public IExternalConnection
    {
    protected:
        ULONG           m_cRef;      //Interface reference count
        LPUNKNOWN       m_pUnkOuter; //For delegation, closure

        ULONG           m_cStrong;   //Strong ref count.

    public:
        CImpIExtConn(LPUNKNOWN);
        ~CImpIExtConn(void);

        STDMETHODIMP QueryInterface(REFIID, LPVOID *);
        STDMETHODIMP_(ULONG) AddRef(void);
        STDMETHODIMP_(ULONG) Release(void);

        STDMETHODIMP_(DWORD) AddConnection(DWORD, DWORD);
        STDMETHODIMP_(DWORD) ReleaseConnection(DWORD, DWORD, BOOL);
    };



/*
 * AUTOAPP.CPP:  Implementation of ICosmoApplication.
 */

//Actions for CAutoApp::MoveSize and CAutoFigure::MoveSize helpers
typedef enum
    {
    MOVESIZEACTION_LEFT=0,
    MOVESIZEACTION_TOP,
    MOVESIZEACTION_WIDTH,
    MOVESIZEACTION_HEIGHT,
    MOVESIZEACTION_GETLEFT,
    MOVESIZEACTION_GETTOP,
    MOVESIZEACTION_GETWIDTH,
    MOVESIZEACTION_GETHEIGHT
    } MOVESIZEACTION;


//"Application" object for OLE Automation
class CAutoApp : public CAutoBase, public ICosmoApplication
    {
    protected:
        BOOL            m_fQuitCalled;

    protected:
        long    MoveSize(MOVESIZEACTION, long, long, long, long);

        virtual void *VTableInterface(void);

    public:
        CAutoApp(PCCosmoFrame);

        //IUnknown methods
        STDMETHODIMP QueryInterface(REFIID riid, PPVOID ppv);
        STDMETHODIMP_(ULONG) AddRef(void);
        STDMETHODIMP_(ULONG) Release(void);

        //ICosmoApplication methods
        STDMETHODIMP_(IDispatch *)  get_Application(void);
        STDMETHODIMP_(IDispatch *)  get_ActiveFigure(void);
        STDMETHODIMP_(BSTR)         get_Caption(void);
        STDMETHODIMP_(IDispatch *)  get_Figures(void);
        STDMETHODIMP_(BSTR)         get_FullName(void);
        STDMETHODIMP_(BSTR)         get_Name(void);
        STDMETHODIMP_(BSTR)         get_Path(void);
        STDMETHODIMP_(long)         get_Left(void);
        STDMETHODIMP_(void)         put_Left(long x);
        STDMETHODIMP_(long)         get_Top(void);
        STDMETHODIMP_(void)         put_Top(long y);
        STDMETHODIMP_(long)         get_Width(void);
        STDMETHODIMP_(void)         put_Width(long cx);
        STDMETHODIMP_(long)         get_Height(void);
        STDMETHODIMP_(void)         put_Height(long cy);
        STDMETHODIMP_(VARIANT_BOOL) get_Visible(void);
        STDMETHODIMP_(void)         put_Visible(VARIANT_BOOL);
        STDMETHODIMP_(BSTR)         get_StatusBar(void);
        STDMETHODIMP_(void)         put_StatusBar(BSTR);
        STDMETHODIMP_(void)         Quit(void);
    };




//AUTOFIGS.CPP:  Implementation of ICosmoFigures collection
class CEnumFigures;
typedef CEnumFigures *PCEnumFigures;


class CAutoFigures : public CAutoBase, public ICosmoFigures
    {
    friend CEnumFigures;

    protected:
        IDispatch    *NewFigure(LPTSTR);
        virtual void *VTableInterface(void);

    public:
        CAutoFigures(PCCosmoClient);
        ~CAutoFigures(void);

        //IUnknown methods
        STDMETHODIMP QueryInterface(REFIID riid, PPVOID ppv);
        STDMETHODIMP_(ULONG) AddRef(void);
        STDMETHODIMP_(ULONG) Release(void);

        //ICosmoFigures methods
        STDMETHODIMP_(IDispatch *) get_Application(void);
        STDMETHODIMP_(IDispatch *) get_Parent(void);
        STDMETHODIMP_(long)        get_Count(void);
        STDMETHODIMP_(IDispatch *) Item(VARIANT);
        STDMETHODIMP_(IDispatch *) Add(void);
        STDMETHODIMP_(IDispatch *) Open(BSTR);
        STDMETHODIMP_(void)        Close(void);
        STDMETHODIMP_(IUnknown *)  _NewEnum(void);
    };

typedef CAutoFigures *PCAutoFigures;

//Enumerator of whatever is held in the collection
class CEnumFigures : public IEnumVARIANT
    {
    protected:
        ULONG       m_cRef;
        HWND        m_hList;
        HINSTANCE   m_hInst;
        ULONG       m_iCur;
        ULONG       m_cItems;

    public:
        CEnumFigures(HINSTANCE);
        ~CEnumFigures(void);

        BOOL    Init(HWND, BOOL);

        //IUnknown members
        STDMETHODIMP         QueryInterface(REFIID, PPVOID);
        STDMETHODIMP_(ULONG) AddRef(void);
        STDMETHODIMP_(ULONG) Release(void);

        //IEnumFORMATETC members
        STDMETHODIMP Next(ULONG, VARIANT *, ULONG *);
        STDMETHODIMP Skip(ULONG);
        STDMETHODIMP Reset(void);
        STDMETHODIMP Clone(IEnumVARIANT **);
    };


/*
 * AUTOFIG.CPP: Implementation of ICosmoFigure object.  This
 * class has no specific data members and only one private
 * function, MoveSize, which is just a helper.  It should be
 * obvious that this class is little more than another route
 * to get at the same functionality we have elsewhere in Cosmo,
 * which is what Automation is really all about when added to
 * an application with a lot of user interface.
 */

class CAutoFigure : public CAutoBase, public ICosmoFigure
    {
    protected:
        long    MoveSize(MOVESIZEACTION, long, long, long, long);

        virtual void *VTableInterface(void);

    public:
        CAutoFigure(PCCosmoDoc);

        //IUnknown members
        STDMETHODIMP         QueryInterface(REFIID, PPVOID);
        STDMETHODIMP_(ULONG) AddRef(void);
        STDMETHODIMP_(ULONG) Release(void);

        //ICosmoFigure members
        STDMETHODIMP_(IDispatch *)  get_Application(void);
        STDMETHODIMP_(IDispatch *)  get_Parent(void);
        STDMETHODIMP_(BSTR)         get_FullName(void);
        STDMETHODIMP_(BSTR)         get_Name(void);
        STDMETHODIMP_(BSTR)         get_Path(void);
        STDMETHODIMP_(VARIANT_BOOL) get_Saved(void);
        STDMETHODIMP_(short)        get_NumberOfPoints(void);
        STDMETHODIMP_(long)         get_BackColor(void);
        STDMETHODIMP_(void)         put_BackColor(long);
        STDMETHODIMP_(long)         get_LineColor(void);
        STDMETHODIMP_(void)         put_LineColor(long);
        STDMETHODIMP_(short)        get_LineStyle(void);
        STDMETHODIMP_(void)         put_LineStyle(short);
        STDMETHODIMP_(long)         get_Left(void);
        STDMETHODIMP_(void)         put_Left(long);
        STDMETHODIMP_(long)         get_Top(void);
        STDMETHODIMP_(void)         put_Top(long);
        STDMETHODIMP_(long)         get_Width(void);
        STDMETHODIMP_(void)         put_Width(long);
        STDMETHODIMP_(long)         get_Height(void);
        STDMETHODIMP_(void)         put_Height(long);
        STDMETHODIMP_(VARIANT_BOOL) get_Visible(void);
        STDMETHODIMP_(void)         put_Visible(VARIANT_BOOL);

        STDMETHODIMP_(void)         Activate(void);
        STDMETHODIMP_(void)         Close(VARIANT, VARIANT);
        STDMETHODIMP_(void)         RevertToSaved(void);
        STDMETHODIMP_(void)         Save(void);
        STDMETHODIMP_(void)         SaveAs(BSTR);
        STDMETHODIMP_(void)         Import(BSTR);
        STDMETHODIMP_(void)         Copy(void);
        STDMETHODIMP_(void)         Cut(void);
        STDMETHODIMP_(void)         Paste(void);
        STDMETHODIMP_(VARIANT_BOOL) AddPoint(short, short);
        STDMETHODIMP_(void)         RemovePoint(void);
    };



//End CHAPTER14MOD



#endif //_COSMO_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -