home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / EVHANDLE.PAK / DIALOG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  6.1 KB  |  192 lines

  1. //----------------------------------------------------------------------------
  2. //  Project EVHANDLE
  3. //  
  4. //  Copyright ⌐ 1996. All Rights Reserved.
  5. //
  6. //  SUBSYSTEM:    EVHANDLE Application
  7. //  FILE:         DIALOG.CPP
  8. //  AUTHOR:       
  9. //
  10. //  OVERVIEW
  11. //  ~~~~~~~~
  12. //  Source file for implementation of TDlgClient (TDialog).
  13. //
  14. //----------------------------------------------------------------------------
  15.  
  16. #include <owl/pch.h>
  17.  
  18. #include "evhandle.h"
  19. #include "dialog.h"
  20.  
  21.  
  22.  
  23. DEFINE_RESPONSE_TABLE2(TDlgClient,TDialog,TVbxEventHandler)
  24. END_RESPONSE_TABLE;
  25.  
  26. //--------------------------------------------------------
  27. // TDlgClient
  28. // ~~~~~~~~~~
  29. // Construction/Destruction handling.
  30. //
  31. TDlgClient::TDlgClient(TWindow* parent, TResId resId, TModule* module)
  32. :
  33.   TDialog(parent, resId, module),
  34. // init all of the sinks, contecting them to the handler methods
  35.   OnEditFocus(TDBEditNotify_MFUNCTOR(*this, &TDlgClient::EditGetFocus)),
  36.   OnEditDataChange(TDBEditNotify_MFUNCTOR(*this, &TDlgClient::EditDataChange)),
  37.   OnEditLoseFocus(TDBEditNotify_MFUNCTOR(*this, &TDlgClient::EditLoseFocus)),
  38.   OnNavBtnClick(TDBNavigatorClick_MFUNCTOR(*this, &TDlgClient::NavBtnClicked)),
  39.   OnRadioChange(TDBRadioGroupNotify_MFUNCTOR(*this, &TDlgClient::RadioGroupChange)),
  40.   OnRadioGetFocus(TDBRadioGroupNotify_MFUNCTOR(*this, &TDlgClient::RadioGroupGetFocus)),
  41.   OnRadioLoseFocus(TDBRadioGroupNotify_MFUNCTOR(*this, &TDlgClient::RadioGroupLoseFocus)),
  42. // init both of the TDBEdit keydown sinks to the same handler method
  43.   OnEditKeyDownSink1(TDBEditKey_MFUNCTOR(*this, &TDlgClient::EditKeyDown)),
  44.   OnEditKeyDownSink2(TDBEditKey_MFUNCTOR(*this, &TDlgClient::EditKeyDown))
  45. {
  46.         OutputWin= new TextWindow(NULL,"Events List");
  47.         Edit1 = new TDBEdit(this,IDC_DBEDIT1);
  48.         Edit2= new TDBEdit(this,IDC_DBEDIT2);
  49.         Nav= new TDBNavigator(this,IDC_DBNAV1);
  50.         RadioGroup= new TDBRadioGroup(this, IDC_DBRADIOG1);
  51. }
  52.  
  53.  
  54. TDlgClient::~TDlgClient()
  55. {
  56.   Destroy();
  57. }
  58.  
  59. void TDlgClient::SetupWindow()
  60. {
  61.   TDialog::SetupWindow();
  62.   // create and show the helper window
  63.   OutputWin->Create();
  64.   OutputWin->Show(SW_SHOW);
  65.  
  66.   // connect the sources to the sinks
  67.   Edit2->OnEnterSource += OnEditFocus;
  68.   Edit2->OnExitSource += OnEditLoseFocus;
  69.   Edit2->OnChangeSource += OnEditDataChange;
  70.   // the two TDBEdit OnKeyDownSource need two different
  71.   // sinks to connect to
  72.   Edit1->OnKeyDownSource += OnEditKeyDownSink1;
  73.   Edit2->OnKeyDownSource += OnEditKeyDownSink2;
  74.   Nav->OnClickSource += OnNavBtnClick;
  75.   RadioGroup->OnChangeSource += OnRadioChange;
  76.   RadioGroup->OnEnterSource += OnRadioGetFocus;
  77.   RadioGroup->OnExitSource += OnRadioLoseFocus;
  78. }
  79.  
  80. // TDBEdit OnKeyDown event handler method, check which TDBEdit control
  81. // the event is for, TDBEdit1 is read only
  82. void TDlgClient::EditKeyDown(TDBEditKeySink&, TDBEdit& edit, SHORT *,TShiftState)
  83. {
  84.    if (edit.HWindow == Edit1->HWindow)
  85.     {
  86.       // make sure the helper window has not been closed by the user
  87.        if (OutputWin->HWindow)
  88.             OutputWin->OutputString("TDBEdit1 Key Down, Read Only TDBEdit");
  89.    }
  90.    else if (edit.HWindow == Edit2->HWindow)
  91.    {
  92.       // make sure the helper window has not been closed by the user
  93.        if (OutputWin->HWindow)
  94.            OutputWin->OutputString("TDBEdit2 Key Down");
  95.    }
  96. }
  97.  
  98. // TDBEdit OnEnter event handler method
  99. void TDlgClient::EditGetFocus(TDBEditNotifySink&, TDBEdit&)
  100. {
  101.    // make sure the helper window has not been closed by the user
  102.    if (OutputWin->HWindow)
  103.        OutputWin->OutputString("TDBEdit2 Get Focus");
  104. }
  105.  
  106. // TDBEdit OnExit event handler method
  107. void TDlgClient::EditLoseFocus(TDBEditNotifySink&, TDBEdit&)
  108. {
  109.    // make sure the helper window has not been closed by the user
  110.     if (OutputWin->HWindow)
  111.          OutputWin->OutputString("TDBEdit2 Lose Focus");
  112. }
  113.  
  114. // TDBEdit OnChange event handler method
  115. void TDlgClient::EditDataChange(TDBEditNotifySink&, TDBEdit&)
  116. {
  117.    // make sure the helper window has not been closed by the user
  118.     if (OutputWin->HWindow)
  119.           OutputWin->OutputString("TDBEdit2 Data Change");
  120. }
  121.  
  122. // TDBRadioGroup OnChange event handler method
  123. void TDlgClient::RadioGroupChange(TDBRadioGroupNotifySink&, TDBRadioGroup&)
  124. {
  125.    // make sure the helper window has not been closed by the user
  126.    if (OutputWin->HWindow)
  127.         OutputWin->OutputString("TDBRadioGroup Data Change");
  128. }
  129.  
  130. // TDBRadioGroup OnEnter event handler method
  131. void TDlgClient::RadioGroupGetFocus(TDBRadioGroupNotifySink&, TDBRadioGroup&)
  132. {
  133.    // make sure the helper window has not been closed by the user
  134.    if (OutputWin->HWindow)
  135.         OutputWin->OutputString("TDBRadioGroup Get Focus");
  136. }
  137.  
  138. // TDBRadioGroup OnExit event handler method
  139. void TDlgClient::RadioGroupLoseFocus(TDBRadioGroupNotifySink&, TDBRadioGroup&)
  140. {
  141.    // make sure the helper window has not been closed by the user
  142.    if (OutputWin->HWindow)
  143.         OutputWin->OutputString("TDBRadioGroup Lose Focus");
  144. }
  145.  
  146.  
  147. // TDBNavigator OnClick event handler method, check which btn was clicked
  148. void TDlgClient::NavBtnClicked(TDBNavigatorClickSink&, TDBNavigator&,
  149.     TNavigateBtn navBtn)
  150. {
  151.       char buf[50];
  152.    switch(navBtn)
  153.    {
  154.        case nbFirst:
  155.            wsprintf(buf,"Nav Click Event, First btn");
  156.           break;
  157.        case nbPrior:
  158.            wsprintf(buf,"Nav Click Event, Prior btn");
  159.           break;
  160.        case nbNext:
  161.            wsprintf(buf,"Nav Click Event,Next btn");
  162.           break;
  163.        case nbLast:
  164.            wsprintf(buf,"Nav Click Event, Last btn");
  165.           break;
  166.        case nbInsert:
  167.            wsprintf(buf,"Nav Click Event, Insert btn");
  168.           break;
  169.        case nbDelete:
  170.            wsprintf(buf,"Nav Click Event, Delete btn");
  171.           break;
  172.        case nbEdit:
  173.            wsprintf(buf,"Nav Click Event, Edit btn");
  174.           break;
  175.        case nbPost:
  176.            wsprintf(buf,"Nav Click Event, Post btn");
  177.           break;
  178.        case nbCancel:
  179.            wsprintf(buf,"Nav Click Event, Cancel btn");
  180.           break;
  181.        case nbRefresh:
  182.            wsprintf(buf,"Nav Click Event, Refresh btn");
  183.           break;
  184.        default:
  185.            wsprintf(buf,"Nav Click Event");
  186.    }
  187.    // make sure the helper window has not been closed by the user
  188.    if (OutputWin->HWindow)
  189.        OutputWin->OutputString(buf);
  190. }
  191.  
  192.