home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / os2thred.zip / PMTHREAD.CPP < prev    next >
C/C++ Source or Header  |  1994-06-05  |  1KB  |  52 lines

  1. // Listing 10 -- PMThread.cpp
  2.  
  3. //------------------------- Includes ------------------------------
  4.  
  5. #define INCL_WIN
  6. #define INCL_DOS
  7.  
  8. #include <os2.h>
  9. #include "PMThread.h"
  10.  
  11. //--------------------------- code --------------------------------
  12.  
  13. PMThread::PMThread (PFNPROC pfn, 
  14.                             USHORT usQSize,
  15.                             ULONG ulStackSize)
  16.                     :    QThread (usQSize, ulStackSize),
  17.                         pfnProc(pfn)
  18. {}
  19.  
  20. PMThread::~PMThread()
  21. {}
  22.  
  23.  
  24. VOID PMThread::Startup(ULONG ulArg)
  25. {
  26.     hab = WinInitialize(0);
  27.     hmq = WinCreateMsgQueue (hab, ulQSize);
  28.     pfnProc(TRUE, ulArg, this);
  29. }
  30.  
  31.  
  32. BOOL PMThread::Shutdown(ULONG ulArg)
  33. {
  34.     pfnProc(FALSE, ulArg, this);
  35.     WinDestroyMsgQueue(hmq);
  36.     WinTerminate(hab);
  37.     return TRUE;
  38. }
  39.  
  40.  
  41. VOID PMThread::SendMsg(    ULONG objAddr,
  42.                                 ULONG msg,
  43.                                 MPARAM mp1, MPARAM mp2)
  44. {
  45.     if (objAddr)
  46.         WinPostMsg ((HWND)objAddr, msg, mp1, mp2);
  47.     else
  48.         WinPostQueueMsg (hmq, msg, mp1, mp2);
  49. }
  50.  
  51. //------------------------ end of file ----------------------------
  52.