Re: Drag-and-drop from Windows Explorer?



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
.



Relevant Pages

  • Re: [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation
    ... > The problem is that our driver and library implement an API that we don't ... > tells the library to register it. ... The app then goes on its merry way until ... at which point it tells the library to deregister the memory. ...
    (Linux-Kernel)
  • Re: Call Back Function in Access
    ... I would guess that they are sending a custom Message to the Window you ... register with the call to their BiSetStatusBackWnd API. ... But Epson must have given you API docs for their DLL. ... >> Access Code, Tips and Tricks ...
    (microsoft.public.access.formscoding)
  • Re: Drag-and-drop from Windows Explorer?
    ... another window and dropped onto the application. ... However, Delphi only seems to support dropping objects dragged from elsewhere in the same application. ... 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. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Exes & Apps
    ... You have nearly no control over windows memory mangment. ... and attain similar "memory cleaning" successes even ... with API calls. ... But AFAIK this is mostly window dressing ...
    (microsoft.public.fox.programmer.exchange)
  • Re: memory
    ... I found task manager and it register ... total memory but system information does not ... >Or you can download a memory tester, ... >> My window xp will not register all of my memory ...
    (microsoft.public.windowsxp.general)

Loading