Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: PhoneDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PhoneDlg.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "PhoneDlg.h"
  16. #include "PhoneEditDlg.h"
  17. #include "..\LgLib\Version.h"
  18. CPhoneDlg::CPhoneDlg()
  19. {
  20. m_pApplication = NULL;
  21. }
  22. CPhoneDlg::~CPhoneDlg()
  23. {
  24. Destroy();
  25. }
  26. UINT CPhoneDlg::DoModal( CApplication* pApplication, HWND hParent )
  27. {
  28. HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE );
  29. m_pApplication = pApplication;
  30. return CGenericWnd::DoModal( hInstance, (LPCTSTR)IDD_PHONE_DLG, hParent );
  31. }
  32. void CPhoneDlg::Destroy()
  33. {
  34. CGenericWnd::DestroyWindow();
  35. }
  36. LRESULT CPhoneDlg::OnInitDialog( WPARAM, LPARAM )
  37. {
  38. HWND hList = GetDlgItem( IDC_LIST );
  39. // add existing items
  40. for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
  41. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
  42. return 0;
  43. }
  44. LRESULT CPhoneDlg::OnCommand( WPARAM wParam, LPARAM )
  45. {
  46. UINT nCtrlId = LOWORD( wParam );
  47. switch( nCtrlId )
  48. {
  49. case IDCANCEL:
  50. OnButtonCancel();
  51. break;
  52. case IDC_BUTTON_ADD:
  53. OnButtonAdd();
  54. break;
  55. case IDC_BUTTON_DELETE:
  56. OnButtonDelete();
  57. break;
  58. case IDC_BUTTON_EDIT:
  59. OnButtonEdit();
  60. break;
  61. default:
  62. if( HIWORD(wParam) == BN_CLICKED )
  63. break;
  64. break;
  65. }
  66. return TRUE;
  67. }
  68. void CPhoneDlg::OnButtonCancel()
  69. {
  70. CGenericWnd::EndDialog( IDCANCEL );
  71. }
  72. void CPhoneDlg::OnButtonAdd()
  73. {
  74. // prepare default rule
  75. CPhoneCallCenter::PHONE_COMMAND PhoneCommand;
  76. memset( &PhoneCommand, 0, sizeof(PhoneCommand) );
  77. // set defaults
  78. PhoneCommand.command.dwPhoneDialTime = 20000;
  79. PhoneCommand.command.dwPhoneDropTime = 10000;
  80. PhoneCommand.command.nPhoneRedialCount = 3;
  81. PhoneCommand.command.nPhoneMessageRepeatCount = 1;
  82. // display edit dialog
  83. CPhoneEditDlg dlg;
  84. if( dlg.DoModal( m_pApplication, GetSafeHwnd(), &PhoneCommand ) == IDOK )
  85. {
  86. // add new rule
  87. m_pApplication->GetCallCenter().GetCommandArray().Add( PhoneCommand );
  88. // reassign datas
  89. SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
  90. for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
  91. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
  92. }
  93. }
  94. void CPhoneDlg::OnButtonDelete()
  95. {
  96. INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
  97. if( nIndex == LB_ERR )
  98. return;
  99. // notify about apdate
  100. m_pApplication->GetCallCenter().GetCommandArray().Remove( nIndex );
  101. // reassign datas
  102. SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
  103. for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
  104. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
  105. }
  106. void CPhoneDlg::OnButtonEdit()
  107. {
  108. INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
  109. if( nIndex == LB_ERR )
  110. return;
  111. CPhoneCallCenter::PPHONE_COMMAND pPhoneCommand = &m_pApplication->GetCallCenter().GetCommandArray()[nIndex];
  112. // display edit dialog
  113. CPhoneEditDlg dlg;
  114. if( dlg.DoModal( m_pApplication, GetSafeHwnd(), pPhoneCommand ) == IDOK )
  115. {
  116. // reassign datas
  117. SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
  118. for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
  119. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
  120. }
  121. }