John Barrat wrote:

 > Steve – thanks for the input, however, I have implemented more 
 > or less what you suggest although not as a class.
 >
 > What I don’t understand is that it works in one application
 > when it’s at Main form yet it won’t when it is a secondary form
 > called up as a modal dialog.
 >
 > This is the code I have used:
 >
 > in the interface bit….
 >
 > public
 >     { Public declarations }
 >     procedure AcceptFiles( var msg : TMessage );
 >       message WM_DROPFILES;
 >
 > and in the implementation….
 >
 > procedure TfmAddLib.FormCreate(Sender: TObject);
 > begin
 >   DragAcceptFiles(LstFiles.Handle, True);
 > end;
 >
 > procedure TfmAddLib.AcceptFiles(var msg : TMessage);
 > const
 >   cnMaxFileNameLen = 255;
 > var
 >   i,
 >   nCount     : integer;
 >   acFileName : array [0..cnMaxFileNameLen] of char;
 > begin
 >   // find out how many files we're accepting
 >   nCount := DragQueryFile( msg.WParam,
 >                            $FFFFFFFF,
 >                            acFileName,
 >                            cnMaxFileNameLen );
 >   // query Windows one at a time for the file name
 >   for i := 0 to nCount-1 do
 >   begin
 >     DragQueryFile( msg.WParam, i,
 >                    acFileName, cnMaxFileNameLen );
 >     if  CheckFileType(acFileName)
 >     And (lstFiles.Items.IndexOf(acFileName) = -1) then
 >       LstFiles.Items.Add(acFileName);
 >   end;
 >
 >   // let Windows know that you're done
 >   DragFinish( msg.WParam );
 > end;
 >
 > If I change my create procedure to use the form handle it
 > works – yet this same code works on another application
 > where the listbox is sitting on the Main Form.

That's because the WM_DROPFILES implementation you've provided is 
a method of the FORM.

In the setup you've created, the our ListBox generates the "files 
dropped" condition. As the initiating HWND, the ListBox receives 
the WM_DROPFILES message back, but has no implementation for it.

The Form, has an implementation to handle it, but it doesn't 
receive the WM_DROPFILES message because it was not the 
initiating HWND.

Make sense?

Anyways, that's the intent of the "interposer" class 
re-implementation of TListBox I sent, it makes the TListBox 
responsible both for generating the dropped files condition as 
well as handling the message when it arrives.

Stephen Posey
[EMAIL PROTECTED]

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to