home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / taman002.zip / TASKMANA.ZIP / src / kTaskMgr.cpp < prev    next >
C/C++ Source or Header  |  2000-04-29  |  4KB  |  209 lines

  1. /* $Id: kTaskMgr.cpp,v 1.1 2000/04/29 19:06:35 stknut Exp $
  2.  *
  3.  * kTaskMgr - OS/2 taskmanager
  4.  *
  5.  * Copyright (c) 2000 knut st. osmundsen
  6.  *
  7.  */
  8.  
  9.  
  10.  
  11. /*******************************************************************************
  12. *   Defined Constants And Macros                                               *
  13. *******************************************************************************/
  14. #define INCL_WIN
  15. #define INCL_GPI
  16. #define INCL_BASE
  17.  
  18.  
  19. /*******************************************************************************
  20. *   Header Files                                                               *
  21. *******************************************************************************/
  22. #include <os2.h>
  23. #ifdef USE_KLIB
  24.     #include <kAssert.h>
  25.     #include <kLog.h>
  26.     #include <kHeap.h>
  27. #else
  28.     #include <malloc.h>
  29. #endif
  30. #include <memory.h>
  31. #include <process.h>
  32. #include <stdio.h>
  33. #include <string.h>
  34.  
  35. #include "kBase.h"
  36. #include "kError.h"
  37. #include "kDlgBase.h"
  38. #include "kMenuBase.h"
  39. #include "kClickDlg.h"
  40. #include "kContainer.h"
  41. #include "kNotebookBase.h"
  42. #include "kNotebookPageBase.h"
  43.  
  44. #include "kQuerySysState.h"
  45.  
  46. #include "kModuleRecord.h"
  47. #include "kModuleContainer.h"
  48.  
  49. #include "kObjectRecord.h"
  50. #include "kObjectContainer.h"
  51.  
  52. #include "kProcessRecord.h"
  53. #include "kProcessContainer.h"
  54.  
  55. #include "kSFNRecord.h"
  56. #include "kSFNContainer.h"
  57.  
  58. #include "kAboutPage.h"
  59. #include "kModulePage.h"
  60. #include "kProcessPage.h"
  61. #include "kSFNPage.h"
  62.  
  63. #include "kTaskMgr.h"
  64. #include "kTaskMgr_defs.h"
  65.  
  66.  
  67.  
  68. /*******************************************************************************
  69. *   Global Variables                                                           *
  70. *******************************************************************************/
  71. /*Note: These are public */
  72. PCSZ   kTaskMgr::pszErrorTitle        = "kTaskMgr - Error";
  73. PCSZ   kTaskMgr::pszInfoTitle         = "kTaskMgr - Information";
  74.  
  75.  
  76.  
  77. /*******************************************************************************
  78. *   Internal Functions                                                         *
  79. *******************************************************************************/
  80. MEMBERTHREAD(kTaskMgr);
  81.  
  82.  
  83.  
  84. /**
  85.  *
  86.  * @returns
  87.  * @param
  88.  * @equiv
  89.  * @precond
  90.  * @methdesc
  91.  * @result
  92.  * @time
  93.  * @sketch
  94.  * @algo
  95.  * @remark
  96.  */
  97. int main(int argc, char **argv)
  98. {
  99.     return kTaskMgr::init(argc, argv);
  100. }
  101.  
  102.  
  103.  
  104. /**
  105.  *
  106.  * @returns
  107.  * @param
  108.  * @equiv
  109.  * @precond
  110.  * @methdesc
  111.  * @result
  112.  * @time
  113.  * @sketch
  114.  * @algo
  115.  * @remark
  116.  */
  117. int kTaskMgr::init(int argc, char **argv)
  118. {
  119.     HAB     hab;
  120.     HMQ     hmq;
  121.     kTaskMgr *pTaskMgr;
  122.  
  123.     hab = WinInitialize(0);          ASSERT(hab);
  124.     hmq = WinCreateMsgQueue(hab, 0); ASSERT(hmq);
  125.  
  126.     try
  127.     {
  128.         /* create kTaskMgr window/object */
  129.         pTaskMgr = new kTaskMgr(hab);
  130.         pTaskMgr->showModal();
  131.  
  132.         delete pTaskMgr;
  133.     }
  134.     catch (kError err)
  135.     {
  136.         err.logError();
  137.         if (err.getErrorNo() != kError::user_cancel)
  138.             err.showError(kTaskMgr::pszErrorTitle);
  139.     }
  140.  
  141.     /* cleanup */
  142.     WinDestroyMsgQueue(hmq);
  143.     WinTerminate(hab);
  144.  
  145.     argc = argc;
  146.     argv = argv;
  147.  
  148.     return 0;
  149. }
  150.  
  151.  
  152.  
  153. /**
  154.  *
  155.  * @returns
  156.  * @param
  157.  * @equiv
  158.  * @precond
  159.  * @methdesc
  160.  * @result
  161.  * @time
  162.  * @sketch
  163.  * @algo
  164.  * @remark
  165.  */
  166. kTaskMgr::kTaskMgr(HAB hab)
  167. : kNotebookBase(DL_KTASKMGR, NULLHANDLE, KTM_NTBK, HWND_DESKTOP)
  168. , hab(hab)
  169. {
  170.     /* Create and insert notebook pages */
  171.     insertPage(new kProcessPage(this), BKA_MAJOR, BKA_LAST);
  172.     insertPage(new kModulePage(this), BKA_MAJOR, BKA_LAST);
  173.     insertPage(new kSFNPage(this), BKA_MAJOR, BKA_LAST);
  174.  
  175.     /* Last */
  176.     insertPage(new kAboutPage(this), BKA_MAJOR, BKA_LAST);
  177. }
  178.  
  179.  
  180.  
  181. /**
  182.  * Destructor for the kTaskMgr class.
  183.  */
  184. kTaskMgr::~kTaskMgr()
  185. {
  186. }
  187.  
  188.  
  189.  
  190. /**
  191.  * Temporary size and focus fix....
  192.  */
  193. ULONG kTaskMgr::showModal()
  194. {
  195.     SWP swp;
  196.     kDlgBase::show();
  197.  
  198.     /* Temporary size fix  */
  199.     WinQueryWindowPos(hwnd,&swp);
  200.     WinSetWindowPos(hwnd, NULLHANDLE, 0, 0, swp.cx-1, swp.cy-1, SWP_SIZE);
  201.  
  202.     /* Try set focus correctly */
  203.     if (paPages != NULL && cPages != 0)
  204.         WinSetFocus(HWND_DESKTOP, WinWindowFromID(paPages[0].hwnd, KPROCPG_CNR));
  205.  
  206.     return kDlgBase::showModal();
  207. }
  208.  
  209.