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;
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"
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 *
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 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
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 !
-----------------------------------------------------------------------------