// ObjManListTarget.cpp: implementation of the CObjManListTarget class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "mw4gameed2.h"
#include "ObjManListTarget.h"
#include "ObjListView.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CObjManListTarget::CObjManListTarget(CObjListView *list)
{
MyList=list;
}

CObjManListTarget::~CObjManListTarget()
{

}

DROPEFFECT CObjManListTarget::OnDragEnter(CWnd* pWnd, COleDataObject* 
                           pDataObject, DWORD dwKeyState, CPoint point )
{   

if(!MyList->CanListDropAt(point))
	return DROPEFFECT_NONE;

if(	dwKeyState&MK_CONTROL)
{
	return DROPEFFECT_COPY;
}

	return DROPEFFECT_MOVE;
} 

void CObjManListTarget::OnDragLeave(CWnd* pWnd)
{
    // Call base class implementation
    COleDropTarget::OnDragLeave(pWnd);
}

DROPEFFECT CObjManListTarget::OnDragOver(CWnd* pWnd, COleDataObject* 
           pDataObject, DWORD dwKeyState, CPoint point )
{
if(!MyList->CanListDropAt(point))
	return DROPEFFECT_NONE;

if(	dwKeyState&MK_CONTROL)
{
	return DROPEFFECT_COPY;
}
	return DROPEFFECT_MOVE;
}

BOOL CObjManListTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, 
                 DROPEFFECT dropEffect, CPoint point )
{ 
/*
	ASSERT(pWnd->IsKindOf(RUNTIME_CLASS(CDrag95View)));

	// insert the new item at the end of the list

	int nLastItem = ((CDrag95View*)pWnd)->GetListCtrl().GetItemCount();	

	// Get the label, description and bitmap ID

	HGLOBAL hgData = pDataObject->GetGlobalData(m_ImageFormat);
	LPSTR lpData = (LPSTR)GlobalLock(hgData);

	CString strLabel(lpData);

	lpData += strLabel.GetLength() + 1;
	CString strDescription(lpData);

	lpData += strDescription.GetLength() + 1;
	DWORD dwBmpID = *(DWORD*)lpData;

	GlobalUnlock(hgData);

	// create and add the new bitmap

	CBitmap bm;
	bm.LoadBitmap (dwBmpID);

	// insert it
	int nNewItem = ((CDrag95View*)pWnd)->m_ImageList.Add (&bm, RGB(192, 192, 192));
	((CDrag95View*)pWnd)->GetListCtrl().InsertItem(nLastItem, strLabel, nNewItem);
	((CDrag95View*)pWnd)->GetListCtrl().SetItemData(nLastItem, dwBmpID);
	((CDrag95View*)pWnd)->GetListCtrl().SetItemText(nLastItem, 1, strDescription);
*/
	MyList->ListDropAt(point);
    return TRUE;
}
