Solved

drag and drop on a desktop icon

Posted on 1998-04-30
7
335 Views
Last Modified: 2010-04-06
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?
0
Comment
Question by:swright243
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1339634
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
0
 

Author Comment

by:swright243
ID: 1339635
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;

0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1339636
Hi

When your program is an icon on the desktop it is not running, so it doesn't process any messages (including WM_DROPFILES).  So, to get around this, Windows passes in the dropped file(s) as command-line parameters when the program runs for the first time.

You thus need 2 methods of trapping the files (without going the whole OLE DropTarget route).

The 1st method is for when the program is already running.  This is your existing method, which you must keep.

The 2nd method is for when the program isn't running.  For this you need to do the following in your FormCreate:

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  for i := 1 to ParamCount do
    PlusMemo1.Lines.Add(ParamStr(i));

  DragAcceptFiles(Handle, True);
end;

That should do the trick.

Cheers,
JB
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:swright243
ID: 1339637
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

0
 

Author Comment

by:swright243
ID: 1339638
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.

0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1339639
Ok.  I don't have Delphi 1 here, but I will look on Monday at work.

Regards,
JimBob
0
 

Author Comment

by:swright243
ID: 1339640
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.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now