home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm7.zip / listthrd.cpp < prev    next >
C/C++ Source or Header  |  1999-06-12  |  3KB  |  78 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1998, 1999  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.     PMB # 181
  21.     11900 Metric Blvd Ste. J
  22.     Austin Tx 78758-3117
  23.     pelliott@io.com
  24. */
  25. // define main thread class.
  26. // define format of work thread started by appmain.cpp
  27. #include "appmain.hpp"
  28. // info shared with list.cpp which runs a frame window.
  29. #include "listrun.hpp"
  30. #include "listthrd.hpp"       // define list threads.
  31.  
  32. #include <iapp.hpp>           // define applications stuff
  33. #include <iexcbase.hpp>       // exception.
  34.  
  35. // define run code for main thread
  36. // this work thread is run by appmain.cpp
  37. // does the main work of this program, but can exit without
  38. // killing other threads that may be started.
  39. void MainThreadFn::run(void)
  40. {
  41.  
  42.     // get current application
  43.     ICurrentApplication & current = IApplication:: current();
  44.  
  45.     // link in dynamic resource library. This will allow someone
  46.     // to configure program for other language by simply
  47.     // compile, link and bind in another resource library dll
  48.     // with strings in other language.
  49.     try
  50.     {
  51.        current.setUserResourceLibrary("listpm");
  52.     }
  53.     // If we can not load resources from dynamic link library, then
  54.     // load the resources built into the application, and user
  55.     // will be stuck with English.
  56.     catch (IException& exc)
  57.     {
  58.        current.setUserResourceLibrary( 0 );
  59.     };
  60.  
  61.     // if no arguements, display empty file on this threads.
  62.     if (current.argc() <2) DisplayFile();
  63.     // else there are some arguements (files) to display.
  64.     else
  65.     {
  66.        // Display all args except the last on other threads
  67.        for ( int i =1; i < current.argc() -1 ; i++ )
  68.        {
  69.            // do somthing with current.argv(i) which is an IString.
  70.            IThread list ( new ListThreadFn ( current.argv(i) ) );
  71.            // display last file on current thread
  72.  
  73.        };
  74.        // display last arg on current thread.
  75.        DisplayFile( current.argv(current.argc() - 1 ) );
  76.     };
  77. }
  78.