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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: SoundDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of SoundDlg.cpp
//----------------------------------------------------------------------------
// SoundDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "SoundDlg.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSoundDlg dialog
CSoundDlg::CSoundDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSoundDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSoundDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSoundDlg::CSoundDlg") );
}
void CSoundDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSoundDlg)
DDX_Control(pDX, IDC_COMBO_ENABLE, m_cbEnable);
DDX_Control(pDX, IDC_LIST_ZONES, m_ListZone);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSoundDlg, CDialog)
//{{AFX_MSG_MAP(CSoundDlg)
ON_NOTIFY(NM_DBLCLK, IDC_LIST_ZONES, OnDblclkListZones)
ON_CBN_KILLFOCUS(IDC_COMBO_ENABLE, OnKillfocusComboEnable)
ON_CBN_SELCHANGE(IDC_COMBO_ENABLE, OnSelchangeComboEnable)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSoundDlg message handlers
BOOL CSoundDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
m_ListZone.GetClientRect( rect );
m_ListZone.InsertColumn( 0, "Zone", LVCFMT_LEFT, rect.Width() / 2, 0 );
m_ListZone.InsertColumn( 1, "Sound alarm", LVCFMT_LEFT, rect.Width() / 2 - 20, 1 );
m_ListZone.SetExtendedStyle( LVS_EX_FULLROWSELECT/* | LVS_EX_CHECKBOXES*/ );
// m_ListZone.SetIconSpacing( 0, 20 );
for( int z = 0; z < m_pSensorArray->GetZoneCount(); z++ )
{
CZone *pZone = m_pSensorArray->GetZone( z );
m_ListZone.InsertItem( z, pZone->GetName() );
if( pZone->IsSoundAlarm() )
m_ListZone.SetItemText( z, 1, "YES" );
else m_ListZone.SetItemText( z, 1, "NO" );
m_ListZone.SetItemData( z, (DWORD)pZone );
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSoundDlg::OnDblclkListZones( NMHDR* pNMHDR, LRESULT* pResult )
{
LPNMLISTVIEW lpNMLV = (LPNMLISTVIEW)pNMHDR;
if( lpNMLV->iItem != -1 )
{
if( lpNMLV->iSubItem==1 )
{
/* CRect rect;
m_ListZone.GetSubItemRect( lpNMLV->iItem, lpNMLV->iSubItem, LVIR_LABEL, rect );
m_cbEnable.SetParent( &m_ListZone );
CRect wRect;
m_cbEnable.GetWindowRect( &wRect );
int shift = ( wRect.Height() - rect.Height() ) / 2;
rect.top -= shift;
rect.bottom -= shift;
m_cbEnable.MoveWindow( &rect );
m_nCurItem = lpNMLV->iItem;
CZone *pZone = (CZone*)m_ListZone.GetItemData( lpNMLV->iItem );
if( pZone->IsSoundAlarm() )
m_cbEnable.SetCurSel( 1 );
else m_cbEnable.SetCurSel( 0 );
m_cbEnable.ShowWindow( SW_SHOW );
m_cbEnable.SetFocus();
*/
CZone *pZone = (CZone*)m_ListZone.GetItemData( lpNMLV->iItem );
if( pZone->IsSoundAlarm() )
{
pZone->EnableSoundAlarm( FALSE );
m_ListZone.SetItemText( lpNMLV->iItem, 1, "NO" );
}
else
{
pZone->EnableSoundAlarm( TRUE );
m_ListZone.SetItemText( lpNMLV->iItem, 1, "YES" );
}
}
}
*pResult = 0;
}
void CSoundDlg::OnKillfocusComboEnable()
{
m_cbEnable.ShowWindow( SW_HIDE );
}
void CSoundDlg::SetSensorArray(CSensorArray *pSensorArray)
{
m_pSensorArray = pSensorArray;
}
void CSoundDlg::OnSelchangeComboEnable()
{
CZone *pZone = (CZone*)m_ListZone.GetItemData( m_nCurItem );
if( m_cbEnable.GetCurSel( ) == 0 )
{
pZone->EnableSoundAlarm( FALSE );
m_ListZone.SetItemText( m_nCurItem, 1, "NO" );
}
else
{
pZone->EnableSoundAlarm( TRUE );
m_ListZone.SetItemText( m_nCurItem, 1, "YES" );
}
}