DATAUSER.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * DATAUSER.H
  3.  * Data Object User Chapter 10
  4.  *
  5.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  6.  *
  7.  * Kraig Brockschmidt, Microsoft
  8.  * Internet  :  kraigb@microsoft.com
  9.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  10.  */
  11. #ifndef _DATAUSER_H_
  12. #define _DATAUSER_H_
  13. #define INC_OLE2
  14. #define CHAPTER10
  15. #include <inole.h>
  16. //Menu Resource ID and Commands
  17. #define IDR_MENU                    1
  18. #define IDM_OBJECTUSEDLL                100
  19. #define IDM_OBJECTUSEEXE                101
  20. #define IDM_OBJECTDATASIZESMALL         102
  21. #define IDM_OBJECTDATASIZEMEDIUM        103
  22. #define IDM_OBJECTDATASIZELARGE         104
  23. #define IDM_OBJECTQUERYGETDATA          105
  24. #define IDM_OBJECTGETDATATEXT           106
  25. #define IDM_OBJECTGETDATABITMAP         107
  26. #define IDM_OBJECTGETDATAMETAFILEPICT   108
  27. #define IDM_OBJECTEXIT                  109
  28. #define IDM_ADVISEMIN                   200
  29. #define IDM_ADVISETEXT                  (IDM_ADVISEMIN+CF_TEXT)
  30. #define IDM_ADVISEBITMAP                (IDM_ADVISEMIN+CF_BITMAP)
  31. #define IDM_ADVISEMETAFILEPICT          (IDM_ADVISEMIN+CF_METAFILEPICT)
  32. #define IDM_ADVISEGETDATA               300
  33. #define IDM_ADVISEREPAINT               301
  34. //DATAUSER.CPP
  35. LRESULT APIENTRY DataUserWndProc(HWND, UINT, WPARAM, LPARAM);
  36. class CAdviseSink;
  37. typedef class CAdviseSink *PCAdviseSink;
  38. /*
  39.  * Application-defined classes and types.
  40.  */
  41. class CApp
  42.     {
  43.     friend LRESULT APIENTRY DataUserWndProc(HWND, UINT, WPARAM
  44.         , LPARAM);
  45.     friend class CAdviseSink;
  46.     protected:
  47.         HINSTANCE       m_hInst;            //WinMain parameters
  48.         HINSTANCE       m_hInstPrev;
  49.         UINT            m_nCmdShow;
  50.         HWND            m_hWnd;             //Main window handle
  51.         BOOL            m_fEXE;             //For tracking menu
  52.         PCAdviseSink    m_pIAdviseSink;
  53.         DWORD           m_dwConn;           //Advise connection
  54.         UINT            m_cfAdvise;         //Advise format
  55.         BOOL            m_fGetData;         //GetData on data change?
  56.         BOOL            m_fRepaint;         //Repaint on data change?
  57.         LPDATAOBJECT    m_pIDataSmall;
  58.         LPDATAOBJECT    m_pIDataMedium;
  59.         LPDATAOBJECT    m_pIDataLarge;
  60.         LPDATAOBJECT    m_pIDataObject;     //Current selection
  61.         UINT            m_cf;
  62.         STGMEDIUM       m_stm;              //Current rendering
  63.         BOOL            m_fInitialized;     //Did CoInitialize work?
  64.     public:
  65.         CApp(HINSTANCE, HINSTANCE, UINT);
  66.         ~CApp(void);
  67.         BOOL Init(void);
  68.         BOOL FReloadDataObjects(BOOL);
  69.         void TryQueryGetData(LPFORMATETC, UINT, BOOL, UINT);
  70.         void Paint(void);
  71.     };
  72. typedef CApp *PAPP;
  73. #define CBWNDEXTRA               sizeof(PAPP)
  74. #define DATAUSERWL_STRUCTURE     0
  75. //This lives with the app to get OnDataChange notifications.
  76. class CAdviseSink : public IAdviseSink
  77.     {
  78.     protected:
  79.         ULONG               m_cRef;
  80.         PAPP                m_pApp;
  81.     public:
  82.         CAdviseSink(PAPP);
  83.         ~CAdviseSink(void);
  84.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  85.         STDMETHODIMP_(ULONG) AddRef(void);
  86.         STDMETHODIMP_(ULONG) Release(void);
  87.         //We only implement OnDataChange for now.
  88.         STDMETHODIMP_(void)  OnDataChange(LPFORMATETC, LPSTGMEDIUM);
  89.         STDMETHODIMP_(void)  OnViewChange(DWORD, LONG);
  90.         STDMETHODIMP_(void)  OnRename(LPMONIKER);
  91.         STDMETHODIMP_(void)  OnSave(void);
  92.         STDMETHODIMP_(void)  OnClose(void);
  93.     };
  94. #endif //_DATAUSER_H_