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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: PhoneDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of PhoneDlg.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "PhoneDlg.h"
#include "PhoneEditDlg.h"
#include "..\LgLib\Version.h"
CPhoneDlg::CPhoneDlg()
{
m_pApplication = NULL;
}
CPhoneDlg::~CPhoneDlg()
{
Destroy();
}
UINT CPhoneDlg::DoModal( CApplication* pApplication, HWND hParent )
{
HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE );
m_pApplication = pApplication;
return CGenericWnd::DoModal( hInstance, (LPCTSTR)IDD_PHONE_DLG, hParent );
}
void CPhoneDlg::Destroy()
{
CGenericWnd::DestroyWindow();
}
LRESULT CPhoneDlg::OnInitDialog( WPARAM, LPARAM )
{
HWND hList = GetDlgItem( IDC_LIST );
// add existing items
for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
return 0;
}
LRESULT CPhoneDlg::OnCommand( WPARAM wParam, LPARAM )
{
UINT nCtrlId = LOWORD( wParam );
switch( nCtrlId )
{
case IDCANCEL:
OnButtonCancel();
break;
case IDC_BUTTON_ADD:
OnButtonAdd();
break;
case IDC_BUTTON_DELETE:
OnButtonDelete();
break;
case IDC_BUTTON_EDIT:
OnButtonEdit();
break;
default:
if( HIWORD(wParam) == BN_CLICKED )
break;
break;
}
return TRUE;
}
void CPhoneDlg::OnButtonCancel()
{
CGenericWnd::EndDialog( IDCANCEL );
}
void CPhoneDlg::OnButtonAdd()
{
// prepare default rule
CPhoneCallCenter::PHONE_COMMAND PhoneCommand;
memset( &PhoneCommand, 0, sizeof(PhoneCommand) );
// set defaults
PhoneCommand.command.dwPhoneDialTime = 20000;
PhoneCommand.command.dwPhoneDropTime = 10000;
PhoneCommand.command.nPhoneRedialCount = 3;
PhoneCommand.command.nPhoneMessageRepeatCount = 1;
// display edit dialog
CPhoneEditDlg dlg;
if( dlg.DoModal( m_pApplication, GetSafeHwnd(), &PhoneCommand ) == IDOK )
{
// add new rule
m_pApplication->GetCallCenter().GetCommandArray().Add( PhoneCommand );
// reassign datas
SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
}
}
void CPhoneDlg::OnButtonDelete()
{
INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
return;
// notify about apdate
m_pApplication->GetCallCenter().GetCommandArray().Remove( nIndex );
// reassign datas
SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
}
void CPhoneDlg::OnButtonEdit()
{
INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
return;
CPhoneCallCenter::PPHONE_COMMAND pPhoneCommand = &m_pApplication->GetCallCenter().GetCommandArray()[nIndex];
// display edit dialog
CPhoneEditDlg dlg;
if( dlg.DoModal( m_pApplication, GetSafeHwnd(), pPhoneCommand ) == IDOK )
{
// reassign datas
SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
for( INT i = 0; i < m_pApplication->GetCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pApplication->GetCallCenter().GetCommandArray()[i].command.pPhoneNumber );
}
}