Guidance
指路人
g.yi.org
software / rapidq / examples / gui / Edit & Richedit / REImage / REImage.hpp

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/***************************************
**
** Images in RichEdit Controls
**
** All Free Source Code
** Code From Hani Atassi from Code Guru
**          (atassi @arabteam2000.com)
** 
** Author: Elliott Sales de Andrade
** E-mail: quantum_analyst @hotmail.com
**
**
***************************************/

class CImageDataObject : IDataObject
{
public: 
  // This static function accepts a pointer to IRochEditOle 
  //   and the bitmap handle.
  // After that the function insert the image in the current 
  //   position of the RichEdit
  //
  static int InsertBitmap(IRichEditOle* pRichEditOle, 
                           HBITMAP hBitmap,
                           DWORD dwFlags); 
 
private:
  ULONG m_ulRefCnt;
  BOOL  m_bRelease;
 
  // The data being passed to the richedit
  //
  STGMEDIUM m_stgmed;
  FORMATETC m_fromat;
 
public:
  CImageDataObject() : m_ulRefCnt(0) {
    m_bRelease = FALSE;
  }
 
  ~CImageDataObject() {
    if (m_bRelease)
      ::ReleaseStgMedium(&m_stgmed);
  }
 
  // Methods of the IUnknown interface
  // 
  STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
  {
    if (iid == IID_IUnknown || iid == IID_IDataObject)
    {
      *ppvObject = this;
      AddRef();
      return S_OK;
    }
    else
      return E_NOINTERFACE;
  }
  STDMETHOD_(ULONG, AddRef)(void)
  {
    m_ulRefCnt++;
    return m_ulRefCnt;
  }
  STDMETHOD_(ULONG, Release)(void)
  {
    if (--m_ulRefCnt == 0)
    {
       delete this;
    }
 
    return m_ulRefCnt;
  }
 
  // Methods of the IDataObject Interface
  //
  STDMETHOD(GetData)(FORMATETC *pformatetcIn, 
                     STGMEDIUM *pmedium) {
    HANDLE hDst;
    hDst = ::OleDuplicateData(m_stgmed.hBitmap, 
                              CF_BITMAP, NULL);
    if (hDst == NULL)
    {
      return E_HANDLE;
    }
 
    pmedium->tymed = TYMED_GDI;
    pmedium->hBitmap = (HBITMAP)hDst;
    pmedium->pUnkForRelease = NULL;
 
    return S_OK;
  }
  STDMETHOD(GetDataHere)(FORMATETC* pformatetc, 
                         STGMEDIUM*  pmedium ) {
    return E_NOTIMPL;
  }
  STDMETHOD(QueryGetData)(FORMATETC*  pformatetc ) {
    return E_NOTIMPL;
  }
  STDMETHOD(GetCanonicalFormatEtc)(FORMATETC*  pformatectIn ,
                                   FORMATETC* pformatetcOut ) {
    return E_NOTIMPL;
  }
  STDMETHOD(SetData)(FORMATETC* pformatetc , 
                     STGMEDIUM*  pmedium , 
                     BOOL  fRelease ) {
  m_fromat = *pformatetc;
  m_stgmed = *pmedium;

  return S_OK;
  }
  STDMETHOD(EnumFormatEtc)(DWORD  dwDirection , 
                           IEnumFORMATETC**  ppenumFormatEtc ) {
    return E_NOTIMPL;
  }
  STDMETHOD(DAdvise)(FORMATETC *pformatetc, 
                     DWORD advf, 
                     IAdviseSink *pAdvSink,
                     DWORD *pdwConnection) {
    return E_NOTIMPL;
  }
  STDMETHOD(DUnadvise)(DWORD dwConnection) {
    return E_NOTIMPL;
  }
  STDMETHOD(EnumDAdvise)(IEnumSTATDATA **ppenumAdvise) {
    return E_NOTIMPL;
  }

  // Some Other helper functions
  //
  void SetBitmap(HBITMAP hBitmap);
  IOleObject *GetOleObject(IOleClientSite *pOleClientSite, 
                           IStorage *pStorage);
};

掌柜推荐
 
 
¥370.00 ·
 
 
¥264.00 ·
 
 
¥648.00 ·
 
 
¥380.00 ·
 
 
¥289.00 ·
 
 
¥1,068.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-10-30 20:14:22