Link to home
Start Free TrialLog in
Avatar of swright243
swright243

asked on

drag and drop on a desktop icon

Using Delphi 1 and 3 I have found that I cannot drop a file onto a desktop icon in Win95 or on a minimized icon in Windows 3.1. and have it load as expected. The program will pop up, but without loading the file. However, once the program is running dropping works fine. What's the trick?
Avatar of JimBob091197
JimBob091197

In your app, are you using DDE to detect each file the user drops or clicks, or are you checking the command-line params (ParamCount and ParamStr)?

JB
Avatar of swright243

ASKER

I don't exactly understand your question, it is not possible to drop a ParamStr on a desktop icon. Here's how I have enabled drag and drop which works fine if the app is not iconized:

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

procedure TForm1.WMDropFiles(var Msg: TMessage);
var
   buff : array[0..255] of char;
   FName: string;
   canDiscard: Boolean;
begin
   Msg.Result := 0;                 {note the 32 bit value}
   DragQueryFile(Msg.wParam, 0, {@}buff, pred(sizeof(buff)));
   FName := strpas(buff);
   FormCloseQuery(Open1, canDiscard);
   if canDiscard then
        PlusMemo1.Lines.LoadFromFile(FName);
   PlusMemo1.Modified := False;
   DragFinish(Msg.wParam);
   BringToFront;
end;

ASKER CERTIFIED SOLUTION
Avatar of JimBob091197
JimBob091197

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your reply was exactly what I needed for Delphi 3 and Win95. But it does not work with the second part of this problem, i.e., Windows 3.1 and Delphi 1. Dropping a file on a minimized applications icon does not load the new file with this technique. I have to have both solutions since my clients are using both at least for the next year.

Thanks

I am going to award a B for this answer since it is only a partial answer though very good nonetheless. But I really need the answer for Win3.1 and Delphi 1.

Ok.  I don't have Delphi 1 here, but I will look on Monday at work.

Regards,
JimBob
I have posted this question again just for Win 3.1 and Delphi 1 since it is very important to me. We can pick this discussion up again there (for another 100!)
Thanks again.