Re: Drag-and-drop from Windows Explorer?
- From: Ryan Styles <ryan@xxxxxxxxxx>
- Date: Tue, 01 Nov 2005 19:59:30 -0500
On Tue, 01 Nov 2005 18:56:14 -0800, Jamie
<jamie_5_not_valid_after_5_Please@xxxxxxxxxxx> staggered into the
room, obviously drunk, and said:
>korax1214@xxxxxxxxx wrote:
>
>that is not a function of delphi but of the win32 api.
>you can capture and register a window to except a
>dropped string message.
> since Delphi does work with the API it makes it very
>easy to do.
> first you use the "DragAcceptFiles(Form1.handle, True)
>to register the form as a window that will accept the
>WM_DROPFILES message.
> you handle this message when it comes in.
> the hDrop Handle is an unlocked memory chuck handle
>that needs to be used in the "DragQueryFile" api., then
>the "DragFinish" API needs to to be called in order to
>free the memory via the handle that was given you.
> normally this handle is an global unlock handle to a
>chuck of memory that some other app created and so it
>must be created using an API to call and not your local
>memory functions. if the drop lands on a window that is
>not registered or the message you handle does not return
>return 0 indicating that you didn't want to process it
>for what ever reason? windows then frees it other wise
>the receiving window must free it.
Thought I would toss this example out there for you that someone was
kind enough to share with me once:
uses
ShellApi;
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Handle, TRUE);
end;
procedure TForm1.WMDROPFILES(var Msg: TWMDropFiles);
var
i, amount: Integer;
FileName: array[0..MAX_PATH] of Char;
begin
inherited;
try
Amount := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, MAX_PATH);
for i := 0 to (Amount - 1) do
begin
DragQueryFile(Msg.Drop, i, FileName, MAX_PATH);
RichEdit1.Lines.LoadFromFile(FileName);
end;
finally
DragFinish(Msg.Drop);
end;
end;
-------
As you can see, this is to load the contents of a file into a
TRichEdit on my form. I am sure you can adapt this to whatever your
needs may be, korax.
Good luck with it!
-- Ryan
.
- References:
- Re: Drag-and-drop from Windows Explorer?
- From: Jamie
- Re: Drag-and-drop from Windows Explorer?
- Prev by Date: Re: Another changing the cursor question.
- Next by Date: Re: Drag-and-drop from Windows Explorer?
- Previous by thread: Re: Drag-and-drop from Windows Explorer?
- Next by thread: Re: Pause im Programm
- Index(es):
Relevant Pages
|
Loading