Link to home
Start Free TrialLog in
Avatar of ziv
ziv

asked on

Problem enabling drag-drop target for a CDialog window...

Hi,
I'm trying to enable simple file dragging into my CDialog based window and encountering a problem.
I followed the instructions in the documentation (how to implement.. for non CView based windows), and here's the chopped code:

// override for COleDropTarget:
class CMyDropTarget : public COleDropTarget
{
public:
        virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
};

class CMyDlg : public CDialog
{
public:
...
        CMyDropTarget droptarget;
...

// and OnCreate handeling
}

..

int CMyDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
        droptarget.Register( (CWnd*)this );
        DragAcceptFiles(TRUE);
}

BOOL CMyDropTarget::OnDrop(CWnd * pWnd, COleDataObject
                *pDataObject, DROPEFFECT dropEffect, CPoint point)
{
        Beep(1000,200);

        return TRUE;
}

Thats about it as described in the How-To documentation. I even initialized the OLE libraries although i dont need ole capabilities.
The result, I can drag items onto my dialog (shows the arrow with a plus sign), but I drop and my OnDrop never gets called (no Beep or breakpoint)...

Any ideas what could be wrong?

Thanks ahead,
Ziv
ASKER CERTIFIED SOLUTION
Avatar of pcs071997
pcs071997

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ziv
ziv

ASKER

If you mean do mydroptarget.Register( GetParent() ) thats no good, since my dialog is the main window of the application and its parent is null.
If you meant something else or got other ideas please reply.