Solved

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

Posted on 1997-07-18
2
675 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 53
iSeries DB2 Query 2 90
Hibernate methods 2 68
Remove Password Protection from pdf (with password) using an command line executable 5 22
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now