Board index » delphi » Opening a text file thought notepad

Opening a text file thought notepad

Hi All

I have a OpenDialog component on my form and is filtered for (*.TXT) files.
Now, what I want to do is, that when the OpenDialog box is executed and the
user selects the TXT file, is that I want it to open in Notepad.
I know the code to execute notepad
WinExec('C:\windows\notepad.exe',SW_SHOWNORMAL) and to hardcode a specific
file WinExec('C:\windows\notepad.exe c:\autoexec.bat ',SW_SHOWNORMAL) .

Now, how would I open the file that the user selected in Opendialog using
notepad..

Any help will be greatly appreciated..

Thanks

Ray

 

Re:Opening a text file thought notepad


Hi !

try This:

  if OpenDialog1.Execute then    {don't do it on cancel}
      WinExec(PChar('notepad.exe '+OpenDialog1.Filename), SW_SHOWNORMAL);

If you want more control with the execution of notepad, try  ShellExecute or CreateProcess (these
subjects pop up in every 50 question or so in average in this NG...).

Bjoerge

Ray skrev i meldingen <370dc98...@news1.mweb.co.za>...

Quote
>Hi All

>I have a OpenDialog component on my form and is filtered for (*.TXT) files.
>Now, what I want to do is, that when the OpenDialog box is executed and the
>user selects the TXT file, is that I want it to open in Notepad.
>I know the code to execute notepad
>WinExec('C:\windows\notepad.exe',SW_SHOWNORMAL) and to hardcode a specific
>file WinExec('C:\windows\notepad.exe c:\autoexec.bat ',SW_SHOWNORMAL) .

>Now, how would I open the file that the user selected in Opendialog using
>notepad..

>Any help will be greatly appreciated..

>Thanks

>Ray

Re:Opening a text file thought notepad


Hi Ray,
Exclude the "c:\windows".   Windows might be installed on D:, or in
c:\win95!
WinExec('notepad.exe '   + mydialog.filename,SW_SHOWNORMAL) .

Quote
On Thu, 8 Apr 1999 11:32:28 +0200, "Ray" <rayg...@iname.com> wrote:
>Hi All

>I have a OpenDialog component on my form and is filtered for (*.TXT) files.
>Now, what I want to do is, that when the OpenDialog box is executed and the
>user selects the TXT file, is that I want it to open in Notepad.
>I know the code to execute notepad
>WinExec('C:\windows\notepad.exe',SW_SHOWNORMAL) and to hardcode a specific
>file WinExec('C:\windows\notepad.exe c:\autoexec.bat ',SW_SHOWNORMAL) .

>Now, how would I open the file that the user selected in Opendialog using
>notepad..

>Any help will be greatly appreciated..

>Thanks

>Ray

Other Threads