Board index » delphi » Help with switching to a windows app

Help with switching to a windows app

Hi,
  I am new to Delphi and I am writing a program that
  does the following:
       displays a list of files (and descriptions of these files) in an
              outline box  [ I have done this successfully]
       calls up the list of files and their descriptions from a text
              file at runtime [ I have done this as well ]
       executes a file when the user clicks on it (in the outline)
           [ I can do this using the ExecuteFile() procedure from the
              Delphi file manager demo program ]
          For example, if the file is 'DOC1.DOC'. clicking on it opens
              up Word for Windows and opens DOC1.DOC
  However what I would also like to do is the following:
      If Word for Windows is already open, then switch to Word, and
      open the file. ( Otherwise what happens is it loads Word all over
       again everytime I click a .DOC file, and this wastes time)
      [The program will need to work for Word .DOC files and Excel .XLS  
     files only, but it won't hurt if it can associate all other files
     with Windows applications as well]
  My questions are:
       How do I check if Word is already open?
  and, If Word is already open, how do I switch to it, instead of        
       opening up a separate copy, and then open up the requested file?

  Also, if its not too much trouble, I'd like to know how I search all
  the current drives and directories to find the file. If the file is
  found I would also like to display the directory in which the file
  was found. (The directory in which the file is,must be displayed      
  separately from the file name.) [ I envisage that this search will not
  take place everytime a file is clicked on, but it will take place once
  when the program is started at the beginning. The program will open
  up the text file that has the list of all the files that can be called
  and then the program will search the entire system to find each of    
  those files, and will associate each filename with a directory. So,
  the string lists will be as follows:
   List of filenames from text file    Directory list created by program
   --------------------------------    ---------------------------------
   doc1.doc                            c:\windows\data
   doc2.doc                            d:\temp
   doc3.doc                            c:\sys
   ........                            ..............  
  Both string lists will be of class TStringList, so that I can work
  with them easily ]

  Any advice would be greatly appreciated :) Thanks in advance.

      Regards
      Alan Abrahams
      ABRAL...@sonnenberg.uct.ac.za
    or ABRAL...@uctvms.uct.ac.za

 

Re:Help with switching to a windows app


Quote
Alan Abrahams <abral...@sonnenberg.uct.ac.za> wrote:
>Hi,
>  I am new to Delphi and I am writing a program that
>  does the following:
>       displays a list of files (and descriptions of these files) in an
>              outline box  [ I have done this successfully]
>       calls up the list of files and their descriptions from a text
>              file at runtime [ I have done this as well ]
>       executes a file when the user clicks on it (in the outline)
>           [ I can do this using the ExecuteFile() procedure from the
>              Delphi file manager demo program ]
>          For example, if the file is 'DOC1.DOC'. clicking on it opens
>              up Word for Windows and opens DOC1.DOC
>  However what I would also like to do is the following:
>      If Word for Windows is already open, then switch to Word, and
>      open the file. ( Otherwise what happens is it loads Word all over
>       again everytime I click a .DOC file, and this wastes time)
>      [The program will need to work for Word .DOC files and Excel .XLS  
>     files only, but it won't hurt if it can associate all other files
>     with Windows applications as well]
>  My questions are:
etc.

>      Regards
>      Alan Abrahams
>      ABRAL...@sonnenberg.uct.ac.za
>    or ABRAL...@uctvms.uct.ac.za

Alan--
  I have code which implements part of this but not all of it. Another
thing you're probably going to want to do is make sure you close Word
and anything else you've opened in Delphi. I'm glad to send you what I
have, which is based on an excellent article on windows, tasks, etc.
by Matt Pietrek in a recent Microsoft Systems Journal. If you've
gotten code from elsewhere, send me a copy. I'm at home now so I'll
need a reminder at work to send it to you; mail me at
rf...@mstarlabs.com.

Other Threads