Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. COleDataObject error

COleDataObject error

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NewVC
    wrote on last edited by
    #1

    Hi All I am geting error when i am useing COleDataObject.I got some example code from net.It's very help full for me but when i am use the code then i am geting error.

    COleDataObject odj1;
    if( odj1.AttachClipboard() )
    {
    if( odj1.IsDataAvailable( CF_HDROP ) )
    {
    STGMEDIUM StgMed;
    FORMATETC fmte = { CF_HDROP,
    (DVTARGETDEVICE FAR *)NULL,
    DVASPECT_CONTENT,
    -1,
    TYMED_HGLOBAL };
    if( odj1.GetData( CF_HDROP, &StgMed, &fmte ) )
    {
    HDROP hDrop = (HDROP)StgMed.hGlobal;
    UINT cFiles = ::DragQueryFile(hDrop, (UINT)-1, NULL, 0);
    CString szText;
    char szFile[MAX_PATH];
    szText="";
    for( UINT count = 0; count < cFiles; count++ )
    {
    ::DragQueryFile(hDrop, count, szFile, sizeof(szFile));
    szText += szFile;
    szText += "\r\n";
    }
    m_pRich->ReplaceSel(szText);
    if (StgMed.pUnkForRelease)
    {
    StgMed.pUnkForRelease->Release();
    }
    else
    {
    ::GlobalFree(StgMed.hGlobal);
    }
    return;
    }
    }
    }

    error geting

    error C2079: 'odj1' uses undefined class 'COleDataObject'
    error C2228: left of '.AttachClipboard' must have class/struct/union
    error C2228: left of '.IsDataAvailable' must have class/struct/union
    error C2228: left of '.GetData' must have class/struct/union

    Plz help me

    C 1 Reply Last reply
    0
    • N NewVC

      Hi All I am geting error when i am useing COleDataObject.I got some example code from net.It's very help full for me but when i am use the code then i am geting error.

      COleDataObject odj1;
      if( odj1.AttachClipboard() )
      {
      if( odj1.IsDataAvailable( CF_HDROP ) )
      {
      STGMEDIUM StgMed;
      FORMATETC fmte = { CF_HDROP,
      (DVTARGETDEVICE FAR *)NULL,
      DVASPECT_CONTENT,
      -1,
      TYMED_HGLOBAL };
      if( odj1.GetData( CF_HDROP, &StgMed, &fmte ) )
      {
      HDROP hDrop = (HDROP)StgMed.hGlobal;
      UINT cFiles = ::DragQueryFile(hDrop, (UINT)-1, NULL, 0);
      CString szText;
      char szFile[MAX_PATH];
      szText="";
      for( UINT count = 0; count < cFiles; count++ )
      {
      ::DragQueryFile(hDrop, count, szFile, sizeof(szFile));
      szText += szFile;
      szText += "\r\n";
      }
      m_pRich->ReplaceSel(szText);
      if (StgMed.pUnkForRelease)
      {
      StgMed.pUnkForRelease->Release();
      }
      else
      {
      ::GlobalFree(StgMed.hGlobal);
      }
      return;
      }
      }
      }

      error geting

      error C2079: 'odj1' uses undefined class 'COleDataObject'
      error C2228: left of '.AttachClipboard' must have class/struct/union
      error C2228: left of '.IsDataAvailable' must have class/struct/union
      error C2228: left of '.GetData' must have class/struct/union

      Plz help me

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Did you include afxole.h as stated in the documentation[^] ?

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups