home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm2.zip / source / listthrd.cpp < prev    next >
Text File  |  1996-07-08  |  3KB  |  77 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1996  Paul Elliott
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     Paul Elliott
  20.     3987 South Gessner #224
  21.     Houston Tx 77063
  22.     Paul.Elliott@Hrnowl.LoneStar.Org
  23. */
  24. // define main thread class.
  25. // define format of work thread started by appmain.cpp
  26. #include "appmain.hpp"
  27. // info shared with list.cpp which runs a frame window.
  28. #include "listrun.hpp"
  29. #include "listthrd.hpp"       // define list threads.
  30.  
  31. #include <iapp.hpp>           // define applications stuff
  32. #include <iexcbase.hpp>       // exception.
  33.  
  34. // define run code for main thread
  35. // this work thread is run by appmain.cpp
  36. // does the main work of this program, but can exit without
  37. // killing other threads that may be started.
  38. void MainThreadFn::run(void)
  39. {
  40.  
  41.     // get current application
  42.     ICurrentApplication & current = IApplication:: current();
  43.  
  44.     // link in dynamic resource library. This will allow someone
  45.     // to configure program for other language by simply
  46.     // compile, link and bind in another resource library dll
  47.     // with strings in other language.
  48.     try
  49.     {
  50.        current.setUserResourceLibrary("listpm");
  51.     }
  52.     // If we can not load resources from dynamic link library, then
  53.     // load the resources built into the application, and user
  54.     // will be stuck with English.
  55.     catch (IException& exc)
  56.     {
  57.        current.setUserResourceLibrary( 0 );
  58.     };
  59.  
  60.     // if no arguements, display empty file on this threads.
  61.     if (current.argc() <2) DisplayFile();
  62.     // else there are some arguements (files) to display.
  63.     else
  64.     {
  65.        // Display all args except the last on other threads
  66.        for ( int i =1; i < current.argc() -1 ; i++ )
  67.        {
  68.            // do somthing with current.argv(i) which is an IString.
  69.            IThread list ( new ListThreadFn ( current.argv(i) ) );
  70.            // display last file on current thread
  71.  
  72.        };
  73.        // display last arg on current thread.
  74.        DisplayFile( current.argv(current.argc() - 1 ) );
  75.     };
  76. }
  77.