Solved

DragDrop files into a ListBox

Posted on 2003-11-04
6
660 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:YuriPutivsky
ID: 9680969
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
ID: 9681083
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
ID: 9681143
For Cut/Paste you have to use another approach...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Accepted Solution

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

0
 

Author Comment

by:MCofer
ID: 9681763
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
ID: 9682281
#include <afxole.h>

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

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

624 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