Solved

MDI Drag & Drop + command line execution

Posted on 1998-08-27
4
306 Views
Last Modified: 2010-04-04
Hi!

I'm making a simple MDI text editor.It based on text editor
sample program in '..\delphi 3\demos\doc'.

I have two questions.

First,How can I coding command line execution?
For example,'notepad sample.txt'.

Second,How can I create MDI child form from drag and drop file?
Drag file from explore and drop file at MDI parent form.How?

Have a nice day!
 
0
Comment
Question by:rnxotj
  • 2
4 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1337893
Hi,
1st,
----
You can use the following code snippet to read the comman line file(say you want to load it to a memo called memo1)
.
  if FileExists(ParamStr(1)) then
  begin
     Memo1.Lines.LoadFromFile(ParamStr(1));
  end else ShowMessage(ParamStr(1)+ 'does not exists');
.
2nd
----
To be able to detect a droped file use the following with your MainForms Handle
   DragAcceptFiles(MyMainWindow.Handle, true);
In this case when ever a file is tried to drop on your main form windows sends WM_DROPFILES message to your main form. So you should capture it and in it you can get the file names as follows:(assume you get wparam of WM_DROPFILES in hDrop interger variable)
var
  FName :  array[0..255] of char;
.
  // this only gets the first filename even multiple files are dropped
  DragQuerryFile(hDrop, 0, FName, sizeof(FName));
  DragFinish(hDrop);
  Memo1.Items.LoadFromFile(FName);
.
DO NOT FORGET TO:
   DragAcceptFiles(MyMainWindow.Handle, false); //at formdestroy

Regards, Igor

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1337894
Hi rnxotj, Igor. If what you want to know is how to execute other apps like notepad, then the easiest way is something like:

ShellExecute(Handle, nil, 'notepad sample.txt', nil, 'D:\', 0);

--Matvey
0
 

Author Comment

by:rnxotj
ID: 1337895
Hi lgor!

It works very well!
Thank you very much..

Have a nice day....
0
 
LVL 5

Accepted Solution

by:
inter earned 30 total points
ID: 1337896
Fine,
Just ask if you need more...
Igor
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 158
oracle global variables 4 70
URL for downloading Google Chrome for Win XP 2 159
DBCtrlGrid, Delphi, Scroll 8 15
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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