home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dho.zip / DHO / SRC / SOURCE.ZIP / nmdlog.cc < prev    next >
C/C++ Source or Header  |  1995-08-27  |  4KB  |  152 lines

  1. /****************************************/
  2. /*    Developer Helper Object Set       */
  3. /*  (C) 1994-95 Thomas E. Bednarz, Jr.  */
  4. /*     All rights reserved              */
  5. /***************************************/
  6.  
  7. /* $Id: nmdlog.cc 1.8 1995/08/21 05:32:14 teb Exp $ */
  8.  
  9.  
  10. #include"nmdlog.h"
  11. #include"applicat.h"
  12. #include"pmutils.h"
  13.  
  14. TNonModalDialog *temp_MDLGTHIS = NULL;
  15.  
  16.  
  17. //-------------------------------------------------------------------
  18. //  TNonModalDialog
  19. TNonModalDialog::TNonModalDialog(ULONG resource):
  20.       TWinBase(resource)
  21. {
  22.    temp_MDLGTHIS = this;
  23. }
  24.  
  25.  
  26. //-------------------------------------------------------------------
  27. //  ~TNonModalDialog
  28. TNonModalDialog::~TNonModalDialog()
  29. {
  30.  
  31. }
  32.  
  33.  
  34. //-------------------------------------------------------------------
  35. //  Init
  36. BOOL TNonModalDialog::init()
  37. {
  38.    SWP swp;
  39.    BOOL ret;
  40.    HAB hab = Application->getAnchorBlock();
  41.  
  42.    hwnd = WinLoadDlg( HWND_DESKTOP,
  43.                           HWND_DESKTOP,
  44.                           (PFNWP)ClientDlogProc,
  45.                           getResHMODULE(),
  46.                           fResource,NULL);
  47.  
  48.    ret =  (hwnd != (HWND)NULL);
  49.  
  50.    if (ret)
  51.    {
  52.       WinQueryTaskSizePos(hab, 0, &swp);
  53.  
  54.       WinSetWindowPos(hwnd,(ULONG)NULL, swp.x,
  55.                           swp.y, 0,0,SWP_SHOW | SWP_MOVE);
  56.    }
  57.    return ret; 
  58. }
  59.  
  60.  
  61. //-------------------------------------------------------------------
  62. //  getClassName
  63. const char *TNonModalDialog::getClassName(void)
  64. {
  65.    return "TNonModalDialog";
  66. }
  67.  
  68.  
  69. //-------------------------------------------------------------------
  70. //  MakeFrame
  71. BOOL TNonModalDialog::MakeFrame(void)
  72. {
  73.    hwnd = WinLoadDlg( HWND_DESKTOP,
  74.                           HWND_DESKTOP,
  75.                           (PFNWP)ClientDlogProc,
  76.                           0,fResource,NULL);
  77.  
  78.    return (hwnd != (HWND)NULL);
  79.  
  80. }
  81.  
  82.  
  83. //-------------------------------------------------------------------
  84. //  doCommand
  85. void TNonModalDialog::doCommand(WinMsg wm)
  86. {
  87.    WinDefDlgProc(wm.hwnd, wm.msg, wm.mp1, wm.mp2);
  88. }
  89.  
  90.  
  91. //-------------------------------------------------------------------
  92. //  doCommand
  93. void TNonModalDialog::doControl(WinMsg wm)
  94. {
  95.     WinDefDlgProc(wm.hwnd, wm.msg, wm.mp1, wm.mp2);
  96. }
  97.  
  98.  
  99. //-------------------------------------------------------------------
  100. //  DlogProc
  101. MRESULT TNonModalDialog::DlogProc(HWND hWnd, ULONG Message, MPARAM mParam1, MPARAM mParam2 )
  102. {
  103.    WinMsg wm;
  104.    wm.hwnd = hWnd;
  105.    wm.msg = Message;
  106.    wm.mp1 = mParam1;
  107.    wm.mp2 = mParam2;
  108.  
  109.    switch (Message)
  110.    {
  111.         case WM_CLOSE:
  112.             WinPostMsg(hWnd, WM_QUIT, 0,0);
  113.             return (MRESULT)FALSE;
  114.         case WM_COMMAND:
  115.             doCommand(wm);
  116.             return (MRESULT)TRUE;
  117.          break;
  118.         case WM_CONTROL:
  119.             doControl(wm);
  120.          return (MRESULT)TRUE;
  121.         default:
  122.            return WinDefDlgProc(hWnd, Message,mParam1, mParam2);
  123.         break;
  124.    }
  125.    return (MRESULT)FALSE;
  126. }
  127.  
  128.  
  129. //-------------------------------------------------------------------
  130. //  ClientDlogProc
  131. MRESULT EXPENTRY ClientDlogProc(HWND hWnd,ULONG iMessage,
  132.        MPARAM mParam1, MPARAM mParam2)
  133. {
  134.  
  135.     TNonModalDialog *pDialog = (TNonModalDialog *)WinQueryWindowULong(hWnd,0);
  136.  
  137.     if (pDialog == 0)
  138.     {
  139.         if (iMessage == WM_INITDLG)
  140.         {
  141.             pDialog = temp_MDLGTHIS;
  142.             WinSetWindowULong(hWnd,0,(ULONG)pDialog);
  143.             return pDialog->DlogProc(hWnd,iMessage,mParam1,mParam2);
  144.         }
  145.         else
  146.             return WinDefDlgProc(hWnd,iMessage,mParam1,mParam2);
  147.     }
  148.     else
  149.         return pDialog->DlogProc(hWnd,iMessage,mParam1,mParam2);
  150. }
  151.  
  152.