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.

155 lines
4.2 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: SoundDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of SoundDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // SoundDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "SoundDlg.h"
  19. #include "..\..\LgLib\Version.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CSoundDlg dialog
  27. CSoundDlg::CSoundDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CSoundDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CSoundDlg)
  31. // NOTE: the ClassWizard will add member initialization here
  32. //}}AFX_DATA_INIT
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSoundDlg::CSoundDlg") );
  34. }
  35. void CSoundDlg::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CSoundDlg)
  39. DDX_Control(pDX, IDC_COMBO_ENABLE, m_cbEnable);
  40. DDX_Control(pDX, IDC_LIST_ZONES, m_ListZone);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CSoundDlg, CDialog)
  44. //{{AFX_MSG_MAP(CSoundDlg)
  45. ON_NOTIFY(NM_DBLCLK, IDC_LIST_ZONES, OnDblclkListZones)
  46. ON_CBN_KILLFOCUS(IDC_COMBO_ENABLE, OnKillfocusComboEnable)
  47. ON_CBN_SELCHANGE(IDC_COMBO_ENABLE, OnSelchangeComboEnable)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CSoundDlg message handlers
  52. BOOL CSoundDlg::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. CRect rect;
  56. m_ListZone.GetClientRect( rect );
  57. m_ListZone.InsertColumn( 0, "Zone", LVCFMT_LEFT, rect.Width() / 2, 0 );
  58. m_ListZone.InsertColumn( 1, "Sound alarm", LVCFMT_LEFT, rect.Width() / 2 - 20, 1 );
  59. m_ListZone.SetExtendedStyle( LVS_EX_FULLROWSELECT/* | LVS_EX_CHECKBOXES*/ );
  60. // m_ListZone.SetIconSpacing( 0, 20 );
  61. for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ )
  62. {
  63. CZone *pZone = m_pSensorArray->GetZone( z );
  64. m_ListZone.InsertItem( z, pZone->GetName() );
  65. if( pZone->IsSoundAlarm() )
  66. m_ListZone.SetItemText( z, 1, "YES" );
  67. else m_ListZone.SetItemText( z, 1, "NO" );
  68. m_ListZone.SetItemData( z, (DWORD)pZone );
  69. }
  70. return TRUE; // return TRUE unless you set the focus to a control
  71. // EXCEPTION: OCX Property Pages should return FALSE
  72. }
  73. void CSoundDlg::OnDblclkListZones( NMHDR* pNMHDR, LRESULT* pResult )
  74. {
  75. LPNMLISTVIEW lpNMLV = (LPNMLISTVIEW)pNMHDR;
  76. if( lpNMLV->iItem != -1 )
  77. {
  78. if( lpNMLV->iSubItem==1 )
  79. {
  80. /* CRect rect;
  81. m_ListZone.GetSubItemRect( lpNMLV->iItem, lpNMLV->iSubItem, LVIR_LABEL, rect );
  82. m_cbEnable.SetParent( &m_ListZone );
  83. CRect wRect;
  84. m_cbEnable.GetWindowRect( &wRect );
  85. int shift = ( wRect.Height() - rect.Height() ) / 2;
  86. rect.top -= shift;
  87. rect.bottom -= shift;
  88. m_cbEnable.MoveWindow( &rect );
  89. m_nCurItem = lpNMLV->iItem;
  90. CZone *pZone = (CZone*)m_ListZone.GetItemData( lpNMLV->iItem );
  91. if( pZone->IsSoundAlarm() )
  92. m_cbEnable.SetCurSel( 1 );
  93. else m_cbEnable.SetCurSel( 0 );
  94. m_cbEnable.ShowWindow( SW_SHOW );
  95. m_cbEnable.SetFocus();
  96. */
  97. CZone *pZone = (CZone*)m_ListZone.GetItemData( lpNMLV->iItem );
  98. if( pZone->IsSoundAlarm() )
  99. {
  100. pZone->EnableSoundAlarm( FALSE );
  101. m_ListZone.SetItemText( lpNMLV->iItem, 1, "NO" );
  102. }
  103. else
  104. {
  105. pZone->EnableSoundAlarm( TRUE );
  106. m_ListZone.SetItemText( lpNMLV->iItem, 1, "YES" );
  107. }
  108. }
  109. }
  110. *pResult = 0;
  111. }
  112. void CSoundDlg::OnKillfocusComboEnable()
  113. {
  114. m_cbEnable.ShowWindow( SW_HIDE );
  115. }
  116. void CSoundDlg::SetSensorArray(CSensorArray *pSensorArray)
  117. {
  118. m_pSensorArray = pSensorArray;
  119. }
  120. void CSoundDlg::OnSelchangeComboEnable()
  121. {
  122. CZone *pZone = (CZone*)m_ListZone.GetItemData( m_nCurItem );
  123. if( m_cbEnable.GetCurSel( ) == 0 )
  124. {
  125. pZone->EnableSoundAlarm( FALSE );
  126. m_ListZone.SetItemText( m_nCurItem, 1, "NO" );
  127. }
  128. else
  129. {
  130. pZone->EnableSoundAlarm( TRUE );
  131. m_ListZone.SetItemText( m_nCurItem, 1, "YES" );
  132. }
  133. }