home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / profile / advprof / profile.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  1.8 KB  |  72 lines

  1. //************************************************************
  2. // GUI Profile Viewer Example
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //************************************************************
  8. #include <istring.hpp>
  9. #include <iexcept.hpp>
  10. #include <imsgbox.hpp>
  11. #include <ithread.hpp>
  12. #include <iwindow.hpp>
  13.  
  14. #include "vprofarg.hpp"
  15. #include "profview.hpp"
  16. #include "enhprof.hpp"
  17.  
  18. int main ( int argc, char *argv[] )
  19.   {
  20.   // Explicitly start PM so that we can display a message box when
  21.   // incorrect input is received.
  22.   IThread::current().initializeGUI();
  23.   int
  24.     rc = 0;
  25.   try
  26.     {
  27.     // Get arguments...
  28.     ViewProfileArgs
  29.       args( argc, argv );
  30.     // Open specified profile...
  31.     EnhancedProfile
  32.       *profile = 0;
  33.     switch ( args.profileType() )
  34.       {
  35.       case ViewProfileArgs::system:
  36.         profile =
  37.           new EnhancedProfile( IProfile::systemProfile() );
  38.         break;
  39.       case ViewProfileArgs::user:
  40.         profile =
  41.           new EnhancedProfile( IProfile::userProfile() );
  42.         break;
  43.       default:
  44.         profile =
  45.           new EnhancedProfile( args.profileName(), false );
  46.       }
  47.     // Open view of selected profile...
  48.     ProfileView
  49.       view( *profile );
  50.     view.open();
  51.     IThread::current().processMsgs();
  52.     delete profile;
  53.     }
  54.   catch ( const IString &msg )
  55.     {
  56.     // Display error message...
  57.     IMessageBox
  58.       msgBox( IWindow::objectWindow() );
  59.     msgBox.show( msg, msgBox.cancelButton );
  60.     rc = 1;
  61.     }
  62.   catch ( const IException &exception )
  63.     {
  64.     // Display report of system-type error...
  65.     IMessageBox
  66.       msgBox( IWindow::objectWindow() );
  67.     msgBox.show( exception );
  68.     rc = 2;
  69.     }
  70.   return rc;
  71.   }
  72.