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