Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DELPHI: FileManager type Drag-Drop?

1 view
Skip to first unread message

Jeffrey Huck

unread,
Apr 9, 1995, 3:00:00 AM4/9/95
to

I'm writing a simple trash can program in Delphi and have managed to get
DragAcceptFiles(HANDLE, True) to work in my FormCreate method when the
program first starts. The problem is that if I restore the window and
then minimize it again Drag/Drop no longer works. I've tried using
DragAcceptFiles in various TForm methods but have had no success. Also,
if I use DragAcceptFiles(APPLICATION.HANDLE, True) in
MyMainForm.FormCreate it looks like it will work (the cursor changes to
a file when I drag over it, even after the reminimize), but I don't know
how to intercept the WM_DROPFILES message from APPLICATION. Any
suggestions?

Thanks

Jeffrey Huck
jeffre...@m.cc.utah.edu

BTW: Here's what MyMainForm.FormCreate looks like...

procedure MyMainForm.FormCreate(SENDER: tOBJECT);
begin
WindowState := wsMINIMIZED;
DragAcceptFiles(HANDLE, True);
{or, DragAcceptFiles(APPLICATION.HANDLE, True); }
..
end;

Andrew Cheshire

unread,
Apr 9, 1995, 3:00:00 AM4/9/95
to
In article: <3m844h$b...@news.cc.utah.edu> jeffre...@m.cc.utah.edu (Jeffrey Huck)
writes:

For how to trap Windows messages see Chapter 7 of the Component Writers Guide. Not sure
how you'll adapt it to your problem though - put a 'message' method in for your form?

----------------------------------------------
Andrew Cheshire an...@axiomati.demon.co.uk
Axiomatic Software CIS: 100273,154
"i forgive you molesworth for those uncouth words"


John N. Hodges

unread,
Apr 10, 1995, 3:00:00 AM4/10/95
to
In article b...@news.cc.utah.edu, jeffre...@m.cc.utah.edu (Jeffrey Huck) writes:
>
>I'm writing a simple trash can program in Delphi and have managed to get
>DragAcceptFiles(HANDLE, True) to work in my FormCreate method when the
>program first starts. The problem is that if I restore the window and
>then minimize it again Drag/Drop no longer works. I've tried using
>DragAcceptFiles in various TForm methods but have had no success. Also,
>if I use DragAcceptFiles(APPLICATION.HANDLE, True) in
>MyMainForm.FormCreate it looks like it will work (the cursor changes to
>a file when I drag over it, even after the reminimize), but I don't know
>how to intercept the WM_DROPFILES message from APPLICATION. Any
>suggestions?
>
>Thanks
>

Jeffery,

You need to create an Applciation.OnMessage function that handles the
wm_OnDropFiles message. I am sorry I don't have code to attach, but I
am at school.....

---
* LT Nick Hodges, USN Naval Postgraduate School *
* jnho...@nps.navy.mil Information Technology Management *
* CIS: 71563,2250 AOL: NHodges Monterey, CA *
* The opinions expressed above are entirely my own and not the Navy's. *
* Visit my homepage: http://vislab-www.nps.navy.mil/~jnhodges *

Mark R. Johnson

unread,
Apr 10, 1995, 3:00:00 AM4/10/95
to
In article <3m844h$b...@news.cc.utah.edu>,

jeffre...@m.cc.utah.edu (Jeffrey Huck) wrote:
>I don't know
>how to intercept the WM_DROPFILES message from APPLICATION. Any
>suggestions?
>
>Thanks
>
>Jeffrey Huck


The following code snippet comes from my enhancements to the Delphi
Text Editor tutorial. It collects the WM_DROPFILES Windows message
and extracts each of the file names. A child window is created to
load each dropped file (CreateChild(fname);). (You must, of course,
have DragAcceptFiles() in the form's OnCreate event handler.)

..

type
TFrameForm = class(TForm)
...
protected
{ Protected declarations }
procedure WMDropFiles(var msg : TMessage); message WM_DROPFILES;
...
end;

..

procedure TFrameForm.WMDropFiles(var msg : TMessage);
var
i, n : word;
size : word;
fname : string;
hdrop : word;
begin
hdrop := msg.WParam;
n := DragQueryFile(hdrop, $ffff, nil, 0);
for i := 0 to (n - 1) do begin
size := DragQueryFile(hdrop, i, nil, 0);
if size < 255 then begin {255 char. string limit - not really a problem}
fname[0] := Chr(size);
DragQueryFile(hdrop, i, @fname[1], size + 1);
CreateChild(fname);
end;
end;
msg.Result := 0;
inherited;
end;

..

I hope this helps!

--Mark Johnson

______________________________________________________________________________
Mark R. Johnson _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Atlanta, GA USA _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
kee...@mindspring.com _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

Anders Ohlsson

unread,
Apr 10, 1995, 3:00:00 AM4/10/95
to jeffre...@m.cc.utah.edu
Hopefully this ends up at c.l.p and at Jeffrey's mailbox...

In article <643067...@axiomati.demon.co.uk>, an...@axiomati.demon.co.uk (Andrew Cheshire) writes:
|> In article: <3m844h$b...@news.cc.utah.edu>

|> writes:
|> >
|> >
|> > I'm writing a simple trash can program in Delphi and have managed to get
|> > DragAcceptFiles(HANDLE, True) to work in my FormCreate method when the
|> > program first starts. The problem is that if I restore the window and
|> > then minimize it again Drag/Drop no longer works. I've tried using
|> > DragAcceptFiles in various TForm methods but have had no success. Also,
|> > if I use DragAcceptFiles(APPLICATION.HANDLE, True) in
|> > MyMainForm.FormCreate it looks like it will work (the cursor changes to

|> > a file when I drag over it, even after the reminimize), but I don't know

|> > how to intercept the WM_DROPFILES message from APPLICATION. Any
|> > suggestions?

Take a look at http://www.it.kth.se/~ao/applau12.zip...

Here's how I did it:

type
TMainForm = class(TForm)
...
procedure FormCreate(Sender: TObject);
...
private
...

{ Here's the important stuff... }

procedure DropFiles(var Msg : TWMDropFiles); message WM_DROPFILES;
...
end;

...

procedure TMainForm.DropFiles(var Msg : TWMDropFiles);
...
DragQueryPoint(Msg.Drop,Point);
...
NrOfFiles := DragQueryFile(Msg.Drop,Word(-1),FileName,BufSize);
...
DragQueryFile(Msg.Drop,0,FileName,BufSize);
...
end;

...

procedure TMainForm.FormCreate(Sender: TObject);
...
DragAcceptFiles(Handle,True);
...
end;


/Anders

-----------------------------------------------------------------------------
! The Windoze program you want is at http://www.it.kth.se/~ao/yacpu20.zip !
! !
! Anders Ohlsson - a...@sto.foa.se - http://www.it.kth.se/~ao !
-----------------------------------------------------------------------------

0 new messages