Solved

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

Posted on 1997-07-18
2
684 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:ziv
2 Comments
 
LVL 1

Accepted Solution

by:
pcs071997 earned 100 total points
ID: 1302676
droptarget.Register( (CWnd*)this );i guess that wrong pointer.maybe GetParent(this);good luck!!!

0
 

Author Comment

by:ziv
ID: 1302677
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.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
viewing source code from eclipse 13 110
wait notify demo infinite loop 3 125
haveThree challenge 22 122
Bartender label printing - switch on and off graphics 3 56
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question