// ObjManTreeTarget.cpp: implementation of the CObjManTreeTarget class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "mw4gameed2.h" #include "ObjManTreeTarget.h" #include "ObjTreeView.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CObjManTreeTarget::CObjManTreeTarget(CObjTreeView *tree) { MyTree=tree; } CObjManTreeTarget::~CObjManTreeTarget() { } DROPEFFECT CObjManTreeTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point ) { if(!MyTree->CanListDropAt(point)) return DROPEFFECT_NONE; if( dwKeyState&MK_CONTROL) { return DROPEFFECT_COPY; } return DROPEFFECT_MOVE; } void CObjManTreeTarget::OnDragLeave(CWnd* pWnd) { // Call base class implementation COleDropTarget::OnDragLeave(pWnd); } DROPEFFECT CObjManTreeTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point ) { if(!MyTree->CanListDropAt(point)) return DROPEFFECT_NONE; if( dwKeyState&MK_CONTROL) { return DROPEFFECT_COPY; } return DROPEFFECT_MOVE; } BOOL CObjManTreeTarget::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); */ MyTree->ListDropAt(point); return TRUE; }