Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drag & Drop between desktop and delphi

Posted on 1999-06-28
10
Medium Priority
?
326 Views
Last Modified: 2010-04-06
I want to be able to check if a file is dragged from a listview in my application to the desktop and in that case execute some code. Also it would be nice to be able to check "incoming" (dragged) files from other applications and the desktop for extension and add them to my listview if they are of a certain format.
0
Comment
Question by:jonassondaniel
[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
  • 2
  • +1
10 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 1384869
There is an excellent drap 'n drop component on DSP (http://sunsite.icm.edu.pl/delphi).

Have a look in the search engine to locate it.

Cheers,

Raymond.

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384870
The filename is dragdrop.zip (i don't have the full URL for you as the DSP site doesn't want to talk to me at the moment :-( )

Cheers,

Raymond.

0
 

Author Comment

by:jonassondaniel
ID: 1384871
If you know how to do it "the hard way" (without a component) I'd like it so much more... :-)

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:ptmcomp
ID: 1384872
There is a "hard way" using the IDropSource and IDropTarget interfaces of the COM and the API function registerdragdrop. A lot of description and examples you'll  find in the win32.hlp of delphi.

Cheers, ptm.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384873
The dragdrop component does it by implementing IDropSource and IDropTarget. It also comes with the source so you can see how to do it...

Cheers,

Raymond.

0
 
LVL 10

Expert Comment

by:Lischke
ID: 1384874
The incoming files can be determined very easy and without the need to use interfaces:

type
  TMainForm
  private
    procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
  end;

procedure TMainForm.WMDropFiles(var Msg: TWMDropFiles);

// the common game here if a file has been dropped on the application

var Buffer: array[0..MAX_PATH] of Char;
    Count, I: Integer;
    List: TStringList;

begin
  Count := DragQueryFile(Msg.Drop, DWORD(-1), nil, 0);
  List := TStringList.Create;
  for I := 0 to Count - 1 do
  begin
    DragQueryFile(Msg.Drop, I, Buffer, MAX_PATH);
    List.Add(Buffer);
  end;
  AddProjectFiles(List);
  List.Free;
  DragFinish(Msg.Drop);
  Msg.Result := 0;
end;

Ciao, Mike
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 1384875
It's a easy solution - but I think you shouldn't use Win3.1 functions to fill a listview with shell icons. Sometimes I think Microsoft should have forbidden Win3.1 functions for Win32 code...
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1384876
ptmcomp, where did your impression come from that I'm using Win31 function? And where did your impression com from that I'm using shell icons in the code above?

Usually, outdated functions are marked in MSDN as such, but I haven't found such a remark in the latest release (april 1999). If your opinion results from the function being there since Win31 then you should also avoid using FillRect (perhaps for this trivial task is also an interface available?). BTW, I can't use a Win3.1 function to retrieve shell icons, as these were first available under Win95.

But you are right when saying that my small routine is only half the solution and one needs IDrop* interfaces to do the other way around (form app. to desktop) or between applications.

Ciao, Mike
0
 

Author Comment

by:jonassondaniel
ID: 1384877
Hmmm.. I appreciate the fact that so many people have something to say about this question... ...but as of yet no one has managed to answer my real question: how do I know when a file has been drag from my application to the desktop? I know this might be tricky to do but I also have a feeling that it can be done. right? wrong?
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1384878
Oh, I think Raymond has indeed given you a solution worth to look at. You won't come around to use the IDrop* interfaces to accomplish what you want, since you need in particular a notification when a drag'n drop operation from your application took place.

Ciao, Mike
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

705 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