Solved

DragDrop files into a ListBox

Posted on 2003-11-04
6
647 Views
Last Modified: 2007-12-19
I have created a simple Dialog Application with a ListBox

m_dwgList.DragAcceptFiles(TRUE);
allows the drag/drop cursor to work correctly
but now how do I capture the droped file name.

The onyl examples I have found drop into a SID window not a ListBox
0
Comment
Question by:MCofer
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:YuriPutivsky
Comment Utility
Use COleDropTarget class
to register your target window and catch OnDrop event like:

class YourClass;
class YourDropTarget : public  COleDropTarget
{
protected:
    virtual BOOL OnDrop(CWnd* pWnd, ...................) { return ((YourClass*)pWnd)->OnDropProcess(.....); }
}

class YourClass : public CWnd
{
friend class YourDropTarget;
private:
    BOOL OnDropProcess(....);
};

Register target OnCreate event and Revoke OnDestroy events

int YourClass::OnCreate(...)
{
    _target.Register(this);
}

void YourClass::OnDestroy(...)
{
    _target.Revoke(this);
}
0
 

Author Comment

by:MCofer
Comment Utility
I'll give it a try
I am basicly a C programmer and may need a little more detailed help.
I'll let you know how it works.

question:
 Will this also work for a Cut & Paste event?
Thanks
0
 
LVL 4

Expert Comment

by:YuriPutivsky
Comment Utility
For Cut/Paste you have to use another approach...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Accepted Solution

by:
YuriPutivsky earned 250 total points
Comment Utility
I forgot to add YourDropTarget class member
class YourClass : public CWnd
{
friend class YourDropTarget;
private:
    BOOL OnDropProcess(....);
   YourDropTarget _target;
};

0
 

Author Comment

by:MCofer
Comment Utility
I had already been trying something  simular
but get the error
error C2504: 'COleDropTarget' : base class undefined
trying to create the class.
did I need to include automation when I created the project?
Can i now just add an Include file or how do I implement COle
0
 

Author Comment

by:MCofer
Comment Utility
#include <afxole.h>

Fixed my initial problem
I'm working now on creating the class
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

6 Experts available now in Live!

Get 1:1 Help Now