Solved

MDI Drag & Drop + command line execution

Posted on 1998-08-27
4
304 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

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

21 Experts available now in Live!

Get 1:1 Help Now