Solved

MDI Drag & Drop + command line execution

Posted on 1998-08-27
4
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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