Solved

MDI Drag & Drop + command line execution

Posted on 1998-08-27
4
303 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Fine,
Just ask if you need more...
Igor
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

10 Experts available now in Live!

Get 1:1 Help Now