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. DROPEFFECT_NONE does not work in conjunction with CF_HDROP

DROPEFFECT_NONE does not work in conjunction with CF_HDROP

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 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.
  • M Offline
    M Offline
    Member 11902265
    wrote on last edited by
    #1

    All, I have a similar code segment as below, and the problem is that when I drag a file from file explorer, the drag over and the drag enter do not allow me to use the DROPEFFECT_NONE. It is overwritten with a DROPEFFECT of DROPEFFECT_COPY.

    BOOL CtestdragDlg::OnInitDialog()
    {
    CDialog::OnInitDialog();

    ::OleInitialize(NULL);
    BOOL bRes = m_Target.Register(&m_List);

    m_cfFormat = RegisterClipboardFormat(_T("{2FCA1C31-D8F1-4f20-8051-B0CCF7B6FD0D}"));

    m_List.InsertColumn(0,_T("First"),0,300);
    m_List.InsertItem(0,_T("Hello"));

    return TRUE; // return TRUE unless you set the focus to a control
    }

    HGLOBAL CtestdragDlg::GetData()
    {
    char Text[5] = "HHHH";
    HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE,strlen(Text)+1);
    char *pChar = (char *)GlobalLock(hGlobal);
    strcpy(pChar,Text);
    GlobalUnlock(hGlobal);
    return hGlobal;
    }

    void CtestdragDlg::OnLvnBegindragList1(NMHDR *pNMHDR, LRESULT *pResult)
    {
    COleDataSource DataSource;
    HGLOBAL hData = GetData();
    if (hData)
    {
    //DataSource.CacheGlobalData(m_cfFormat,hData);
    DataSource.CacheGlobalData(CF_HDROP,hData);

    DROPEFFECT DropEffect = DataSource.DoDragDrop();
    }
    *pResult = 0;
    }

    DROPEFFECT CMyTarget::OnDragOver(CWnd* pWnd,COleDataObject* pDataObject,DWORD dwKeyState,CPoint point)
    {
    return DROPEFFECT_NONE;
    }

    When the DROPEFFECT_NONE is returned in the OnDragOver event, I get the effect as if it were in DROPEFFECT_COPY. The COLEDragTarget seems to get the correct value back, but then in goes into OLE32 code that I can figure out.

    D 1 Reply Last reply
    0
    • M Member 11902265

      All, I have a similar code segment as below, and the problem is that when I drag a file from file explorer, the drag over and the drag enter do not allow me to use the DROPEFFECT_NONE. It is overwritten with a DROPEFFECT of DROPEFFECT_COPY.

      BOOL CtestdragDlg::OnInitDialog()
      {
      CDialog::OnInitDialog();

      ::OleInitialize(NULL);
      BOOL bRes = m_Target.Register(&m_List);

      m_cfFormat = RegisterClipboardFormat(_T("{2FCA1C31-D8F1-4f20-8051-B0CCF7B6FD0D}"));

      m_List.InsertColumn(0,_T("First"),0,300);
      m_List.InsertItem(0,_T("Hello"));

      return TRUE; // return TRUE unless you set the focus to a control
      }

      HGLOBAL CtestdragDlg::GetData()
      {
      char Text[5] = "HHHH";
      HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE,strlen(Text)+1);
      char *pChar = (char *)GlobalLock(hGlobal);
      strcpy(pChar,Text);
      GlobalUnlock(hGlobal);
      return hGlobal;
      }

      void CtestdragDlg::OnLvnBegindragList1(NMHDR *pNMHDR, LRESULT *pResult)
      {
      COleDataSource DataSource;
      HGLOBAL hData = GetData();
      if (hData)
      {
      //DataSource.CacheGlobalData(m_cfFormat,hData);
      DataSource.CacheGlobalData(CF_HDROP,hData);

      DROPEFFECT DropEffect = DataSource.DoDragDrop();
      }
      *pResult = 0;
      }

      DROPEFFECT CMyTarget::OnDragOver(CWnd* pWnd,COleDataObject* pDataObject,DWORD dwKeyState,CPoint point)
      {
      return DROPEFFECT_NONE;
      }

      When the DROPEFFECT_NONE is returned in the OnDragOver event, I get the effect as if it were in DROPEFFECT_COPY. The COLEDragTarget seems to get the correct value back, but then in goes into OLE32 code that I can figure out.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      So is your target window receiving the copy, or is it disallowing it?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      M 1 Reply Last reply
      0
      • D David Crow

        So is your target window receiving the copy, or is it disallowing it?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        M Offline
        M Offline
        Member 11902265
        wrote on last edited by
        #3

        The target window (CTreeCtrl) is returning on the OnDragEnter and OnDragOver a DROPEFFECT_NONE. The cursor is displaying as if I returned a DROPEFFECT_COPY. I can return back other types like DROPEFFECT_MOVE or DROPEFFECT_LINK and those behave properly. The interesting thing is that OnDrop is not called if I do return DROPEFFECT_NONE, and it is called in the case I do DROPEFFECT_MOVE, etc. So the function calling is correct. It is only the cursor that is being displayed that is not correct. Also in this same application within other windows, I am using other implementations (different window types) of COLEDropTarget and the cursor behavior is correct. I have no clue where else to look at this time. As a workaround, I'm using the CImageList Drag concept to display a NOT symbol beside the cursor when DROPEFECT is NONE.

        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