home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 038 / dho_9a.zip / WINDOW.CC < prev    next >
Text File  |  1995-01-04  |  4KB  |  170 lines

  1. // Developer Helper Object Set, (C) 1994 Thomas E. Bednarz, Jr.
  2. //  All rights reserved
  3.  
  4.  
  5. #include"window.h"
  6. #include<os2.h>
  7.  
  8.  
  9. BOOL TWindow::fInitialized = FALSE;
  10.  
  11.  
  12.  
  13. TWindow *tempTHIS;
  14.  
  15. //-------------------------------------------------------------------
  16. //  TWindow
  17. TWindow::TWindow(CHAR *title, ULONG flags, ULONG resource):
  18.    TWinBase(resource)
  19. {
  20.    tempTHIS = this;
  21.    flCreateFlags = flags;
  22.  
  23.    fTitle = title;
  24. }
  25.  
  26.  
  27. //-------------------------------------------------------------------
  28. //  ~TWindow
  29. TWindow::~TWindow()
  30. {
  31.  
  32. }
  33.  
  34.  
  35. //-------------------------------------------------------------------
  36. //  Init
  37. BOOL TWindow::Init(HAB hab)
  38. {
  39.    Register(hab);
  40.    return MakeFrame();
  41. }
  42.  
  43.  
  44. //-------------------------------------------------------------------
  45. //  ShowWindow
  46. BOOL TWindow::ShowWindow(int nCmdShow)
  47.    return WinShowWindow(hwndFrame,nCmdShow);
  48. }
  49.      
  50.  
  51. //-------------------------------------------------------------------
  52. //  Wpdate
  53. BOOL TWindow::Update(void)
  54.    return WinUpdateWindow(hwndFrame);
  55. }
  56.  
  57.  
  58. //-------------------------------------------------------------------
  59. //  WndProc
  60. MRESULT TWindow::WndProc(HWND hWnd, ULONG Message, MPARAM mParam1, MPARAM mParam2 )
  61. {
  62.    switch(Message)
  63.    {
  64.       case WM_ERASEBACKGROUND:
  65.          return (MRESULT)TRUE;
  66.  
  67.       case WM_COMMAND:
  68.             return doCommand( hWnd, Message, mParam1, mParam2);
  69.          break;
  70.  
  71.       case WM_DESTROY:
  72.             return (MRESULT)FALSE;
  73.          break;
  74.  
  75. //      case WM_PAINT:
  76. //            return (MRESULT) FALSE;
  77. //         break;
  78.  
  79.       default:
  80.          return WinDefWindowProc(hWnd, Message, mParam1, mParam2);
  81.    }
  82.    return (MRESULT)FALSE;
  83. }
  84.  
  85.  
  86. //-------------------------------------------------------------------
  87. //  getClassName
  88. const char *TWindow::getClassName(void)
  89. {
  90.    return "TWindow";
  91. }
  92.  
  93.  
  94. //-------------------------------------------------------------------
  95. //  Register
  96. void TWindow::Register(HAB anchor_block)
  97. {
  98.    if (!fInitialized)
  99.    {
  100.      WinRegisterClass(anchor_block, (PSZ)getClassName(),
  101.                     ClientWndProc, 0,sizeof(TWindow));
  102.      fInitialized = TRUE;
  103.    }
  104.  
  105. }
  106.  
  107.  
  108. //-------------------------------------------------------------------
  109. //  MakeFrame
  110. BOOL TWindow::MakeFrame(void)
  111. {
  112.    hwndFrame = WinCreateStdWindow (HWND_DESKTOP,  WS_VISIBLE,
  113.                &flCreateFlags ,(PSZ)getClassName(), (PSZ)fTitle, 0L,
  114.                (HMODULE) NULL, fResource, (PHWND)&hwndClient);
  115.  
  116.  
  117.    return (hwndFrame!=(HWND)NULL);
  118.    return TRUE;
  119. }
  120.  
  121.  
  122. //-------------------------------------------------------------------
  123. //  doCommand
  124. MRESULT TWindow::doCommand(HWND hWnd, ULONG Message, MPARAM mParam1, MPARAM mParam2)
  125. {
  126.    return WinDefWindowProc(hWnd, Message, mParam1, mParam2);
  127. }
  128.  
  129.  
  130. //-------------------------------------------------------------------
  131. //  ClientWndProc
  132. MRESULT EXPENTRY TWindow::ClientWndProc(HWND hWnd,ULONG iMessage,
  133.     MPARAM mParam1, MPARAM mParam2)
  134. {
  135.  
  136.     TWindow *pWindow = (TWindow *)WinQueryWindowULong(hWnd,0);
  137.  
  138.     if (pWindow == 0) 
  139.     {
  140.         if (iMessage == WM_CREATE) 
  141.         {
  142.             pWindow = tempTHIS;
  143.             WinSetWindowULong(hWnd,0,(ULONG)pWindow);
  144.             return pWindow->WndProc(hWnd,iMessage,mParam1,mParam2);
  145.         } 
  146.         else
  147.             return WinDefWindowProc(hWnd,iMessage,mParam1,mParam2);
  148.     } 
  149.     else
  150.         return pWindow->WndProc(hWnd,iMessage,mParam1,mParam2);
  151. }
  152.  
  153.  
  154. //-------------------------------------------------------------------
  155. //  GetClient
  156. HWND TWindow::GetClient(void)
  157. {
  158.    return hwndClient;
  159. }
  160.  
  161. //-------------------------------------------------------------------
  162. //  scrollWin
  163. void TWindow::scrollWin(LONG hs, LONG vs)
  164. {
  165.    WinScrollWindow(GetClient(),hs, vs, (PRECTL)NULL,
  166.         (PRECTL)NULL, (HRGN)NULLHANDLE,(PRECTL)NULL,0);
  167. }
  168.