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. OLE problem with drag and drop

OLE problem with drag and drop

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomquestion
3 Posts 1 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.
  • J Offline
    J Offline
    jmostei
    wrote on last edited by
    #1

    I have implemented drag and drop on my new aplication and i have a strange error. In InitInstance method of app object i call AfxInitOle() function. Lets we call source window A and target window B. In A´s OnCreate message handler i use the following code: medium.tymed = TYMED_FILE; medium.lpszFileName = (unsigned short *)((LPCSTR)(new CString("TempDragDrop.dat"))); source->CacheData(((CLightControllerApp *)AfxGetApp())->ID_FOCUS_FORMAT,&medium); In B´s OnCreate message handler i use the following code: target.Register(this); And on OnDestroy message handler of B window I use: target.Revoke(); I have no idea of what is going wrong, so please help me. Many thanks to all you and sorry for my poor english.

    J 2 Replies Last reply
    0
    • J jmostei

      I have implemented drag and drop on my new aplication and i have a strange error. In InitInstance method of app object i call AfxInitOle() function. Lets we call source window A and target window B. In A´s OnCreate message handler i use the following code: medium.tymed = TYMED_FILE; medium.lpszFileName = (unsigned short *)((LPCSTR)(new CString("TempDragDrop.dat"))); source->CacheData(((CLightControllerApp *)AfxGetApp())->ID_FOCUS_FORMAT,&medium); In B´s OnCreate message handler i use the following code: target.Register(this); And on OnDestroy message handler of B window I use: target.Revoke(); I have no idea of what is going wrong, so please help me. Many thanks to all you and sorry for my poor english.

      J Offline
      J Offline
      jmostei
      wrote on last edited by
      #2

      i have found it, and i wish i can help anyone who finds the same problem... The cuestion is that when you call the CacheData function, you must care every value in the STGMEDIUM and FORMATETC structures. A good idea is to make something like this: ZeroMemory(pMedium, sizeof(STGMEDIUM )) and ZeroMemory(pFormatetc, sizeof(FORMATETC )) before beginning to give values to its members. You must remember too that since these two structures are passed to CacheData() they arent owned by aplication, that means for example that you can do :)something like this: pMedium = new STGMEDIUM; ...; ...->CacheData(...,pMedium, ...); ...; delete pMedium; because this will surely cause a program´s crash.:)

      1 Reply Last reply
      0
      • J jmostei

        I have implemented drag and drop on my new aplication and i have a strange error. In InitInstance method of app object i call AfxInitOle() function. Lets we call source window A and target window B. In A´s OnCreate message handler i use the following code: medium.tymed = TYMED_FILE; medium.lpszFileName = (unsigned short *)((LPCSTR)(new CString("TempDragDrop.dat"))); source->CacheData(((CLightControllerApp *)AfxGetApp())->ID_FOCUS_FORMAT,&medium); In B´s OnCreate message handler i use the following code: target.Register(this); And on OnDestroy message handler of B window I use: target.Revoke(); I have no idea of what is going wrong, so please help me. Many thanks to all you and sorry for my poor english.

        J Offline
        J Offline
        jmostei
        wrote on last edited by
        #3

        i have found it, and i wish i can help anyone who finds the same problem... The cuestion is that when you call the CacheData function, you must care every value in the STGMEDIUM and FORMATETC structures. A good idea is to make something like this: ZeroMemory(pMedium, sizeof(STGMEDIUM )) and ZeroMemory(pFormatetc, sizeof(FORMATETC )) before beginning to give values to its members. You must remember too that since these two structures are passed to CacheData() they arent owned by aplication, that means for example that you can do :)something like this: pMedium = new STGMEDIUM; ...; ...->CacheData(...,pMedium, ...); ...; delete pMedium; because this will surely cause a program´s crash.:)

        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