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 / MODDLOG.CC < prev    next >
Text File  |  1994-10-13  |  4KB  |  163 lines

  1. // Developer Helper Object Set, (C) 1994 Thomas E. Bednarz, Jr.
  2. //  All rights reserved
  3. #include"moddlog.h"
  4.  
  5. TModalDialog *tempTHIS;
  6.  
  7.  
  8. //-------------------------------------------------------------------
  9. //  TModalDialog
  10. TModalDialog::TModalDialog(ULONG resource, TWinBase *owner, void *buffer):TWinBase(resource)
  11. {
  12.    fBuffer = buffer;
  13.    fOwner = owner;
  14.    tempTHIS = this;
  15.    MakeFrame();
  16. }
  17.  
  18.  
  19. //-------------------------------------------------------------------
  20. //  ~TModalDialog
  21. TModalDialog::~TModalDialog()
  22. {
  23.    WinDestroyWindow(hwndFrame);
  24. }
  25.  
  26.  
  27. //-------------------------------------------------------------------
  28. //  MakeFrame
  29. BOOL TModalDialog::MakeFrame(void)
  30. {
  31.    hwndFrame = WinLoadDlg( HWND_DESKTOP,
  32.                             fOwner->hwndFrame,
  33.                              (PFNWP)ClientDlogProc,
  34.                             0,fResource,NULL);
  35.  
  36.    return (hwndFrame != (HWND)NULL);
  37.  
  38. }
  39.  
  40.  
  41. //-------------------------------------------------------------------
  42. //  Init
  43. BOOL TModalDialog::Init(HAB hab)
  44. {
  45.    Init();
  46. }
  47.  
  48.  
  49. //-------------------------------------------------------------------
  50. //  Init
  51. void  TModalDialog::Init()
  52. {
  53.  
  54. }
  55.  
  56.  
  57. //-------------------------------------------------------------------
  58. //  Execute
  59. void TModalDialog::Execute()
  60. {
  61.    WinProcessDlg(hwndFrame);
  62. }
  63.  
  64.  
  65. //-------------------------------------------------------------------
  66. //  getClassName
  67. const char *TModalDialog::getClassName()
  68. {
  69.    return "TModalDialog";
  70. }
  71.  
  72.  
  73. //-------------------------------------------------------------------
  74. //  DlogProc
  75. MRESULT TModalDialog::DlogProc(HWND hWnd, ULONG Message, MPARAM mParam1, MPARAM mParam2 )
  76. {
  77.    switch (Message)
  78.    {
  79.    case WM_COMMAND:
  80.        return doCommand(hWnd, Message, mParam1, mParam2);
  81.       break;
  82.    case WM_INITDLG:
  83.          Init();
  84.       break;
  85.    default:
  86.       return WinDefDlgProc(hWnd, Message, mParam1, mParam2);
  87.    }
  88.    return (MRESULT)FALSE;
  89. }
  90.  
  91.  
  92. //-------------------------------------------------------------------
  93. //  doCommand
  94. MRESULT TModalDialog::doCommand(HWND hWnd, ULONG Message, MPARAM mParam1, MPARAM mParam2)
  95. {
  96.    SHORT command = SHORT1FROMMP(mParam1);
  97.    if (command = DID_OK)
  98.    {
  99.     if (doOK())
  100.       WinDismissDlg(hwndFrame,1);
  101.       return TRUE;
  102.     }
  103.    else if (command = DID_CANCEL)
  104.    {
  105.        doCancel();
  106.       WinDismissDlg(hwndFrame,1);
  107.       return TRUE;
  108.    }
  109.    else 
  110.       return FALSE;
  111. }
  112.  
  113.  
  114. //-------------------------------------------------------------------
  115. //  doOk
  116. SHORT TModalDialog::doOK(void)
  117. {
  118.    SetData();
  119.    return 1;
  120. }
  121.  
  122.  
  123. //-------------------------------------------------------------------
  124. //  SetData
  125. void TModalDialog::SetData()
  126. {
  127.  
  128. }
  129.  
  130.  
  131. //-------------------------------------------------------------------
  132. //  doCancel
  133. void TModalDialog::doCancel(void)
  134. {
  135.  
  136. }
  137.  
  138.  
  139. //-------------------------------------------------------------------
  140. //  ClientDlogProc
  141. MRESULT EXPENTRY TModalDialog::ClientDlogProc(HWND hWnd,ULONG iMessage,
  142.     MPARAM mParam1, MPARAM mParam2)
  143. {
  144.  
  145.     TModalDialog *pDialog = (TModalDialog *)WinQueryWindowULong(hWnd,0);
  146.  
  147.     if (pDialog == 0) 
  148.     {
  149.         if (iMessage == WM_INITDLG)
  150.         {
  151.             pDialog = tempTHIS;
  152.             WinSetWindowULong(hWnd,0,(ULONG)pDialog);
  153.             return pDialog->DlogProc(hWnd,iMessage,mParam1,mParam2);
  154.         }
  155.         else
  156.             return WinDefDlgProc(hWnd,iMessage,mParam1,mParam2);
  157.     } 
  158.     else
  159.         return pDialog->DlogProc(hWnd,iMessage,mParam1,mParam2);
  160. }
  161.  
  162.  
  163.