Public Member Functions

TreeDropTarget Class Reference

OLE drop target for tree controls. More...

#include <treedroptarget.h>

Inheritance diagram for TreeDropTarget:
Inheritance graph
[legend]
Collaboration diagram for TreeDropTarget:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TreeDropTarget (HWND hTargetWnd)
virtual bool OnDrop (FORMATETC *pFmtEtc, STGMEDIUM &medium, DWORD *pdwEffect)
virtual HRESULT STDMETHODCALLTYPE DragOver (DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
virtual HRESULT STDMETHODCALLTYPE DragLeave (void)

Detailed Description

OLE drop target for tree controls.

Definition at line 13 of file treedroptarget.h.


Constructor & Destructor Documentation

TreeDropTarget::TreeDropTarget ( HWND  hTargetWnd ) [inline]

Definition at line 16 of file treedroptarget.h.

: IDropTargetImpl(hTargetWnd) {}

Member Function Documentation

virtual HRESULT STDMETHODCALLTYPE TreeDropTarget::DragLeave ( void   ) [inline, virtual]

Reimplemented from IDropTargetImpl.

Definition at line 75 of file treedroptarget.h.

References IDropTargetImpl::m_hTargetWnd.

    {
        TreeView_SelectDropTarget(m_hTargetWnd, NULL);

        return IDropTargetImpl::DragLeave();
    }
virtual HRESULT STDMETHODCALLTYPE TreeDropTarget::DragOver ( DWORD  grfKeyState,
POINTL  pt,
DWORD __RPC_FAR *  pdwEffect 
) [inline, virtual]

Reimplemented from IDropTargetImpl.

Definition at line 58 of file treedroptarget.h.

References IDropTargetImpl::m_hTargetWnd, and ScreenToClient().

    {
        TVHITTESTINFO hit;
        hit.pt = (POINT&)pt;
        ScreenToClient(m_hTargetWnd, &hit.pt);
        hit.flags = TVHT_ONITEM;
        HTREEITEM hItem = TreeView_HitTest(m_hTargetWnd,&hit);

        if (hItem != NULL)
            TreeView_SelectDropTarget(m_hTargetWnd, hItem);

        return IDropTargetImpl::DragOver(grfKeyState, pt, pdwEffect);
    }

Here is the call graph for this function:

virtual bool TreeDropTarget::OnDrop ( FORMATETC *  pFmtEtc,
STGMEDIUM &  medium,
DWORD *  pdwEffect 
) [inline, virtual]

Todo:
Add the code to handle Copy
Todo:
Add the code to handle Move

Implements IDropTargetImpl.

Definition at line 18 of file treedroptarget.h.

References IDropTargetImpl::m_hTargetWnd.

    {
        if (pFmtEtc->cfFormat == CF_HDROP && medium.tymed == TYMED_HGLOBAL)
        {
            HDROP hDrop = (HDROP)GlobalLock(medium.hGlobal);
            if (hDrop != NULL)
            {
                TCHAR szFileName[MAX_PATH];

                UINT cFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);

                for(UINT i = 0; i < cFiles; ++i)
                {
                    DragQueryFile(hDrop, i, szFileName, sizeof(szFileName));

                    if (DROPEFFECT_COPY & *pdwEffect)
                    {
                         // copy the file or dir

                        ///@todo Add the code to handle Copy

                    }
                    else if (DROPEFFECT_MOVE & *pdwEffect)
                    {
                         // move the file or dir

                        ///@todo Add the code to handle Move

                    }
                }
                //DragFinish(hDrop); // base class calls ReleaseStgMedium
            }
            GlobalUnlock(medium.hGlobal);
        }

        TreeView_SelectDropTarget(m_hTargetWnd, NULL);

        return true; //let base free the medium
    }

The documentation for this class was generated from the following file:

ROS Explorer Source Code Documentation
generated on 02.01.2013 by doxygen

ROS Explorer Homepage