Solved

drag and drop on a desktop icon

Posted on 1998-04-30
7
334 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

12 Experts available now in Live!

Get 1:1 Help Now