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.
632 lines
18 KiB
632 lines
18 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: MainDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of MainDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// MainDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "MultiIPIClient.h"
|
|
#include "MainDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAboutDlg dialog used for App About
|
|
|
|
class CAboutDlg : public CDialog
|
|
{
|
|
public:
|
|
CAboutDlg();
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CAboutDlg)
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
//}}AFX_DATA
|
|
|
|
// ClassWizard generated virtual function overrides
|
|
//{{AFX_VIRTUAL(CAboutDlg)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementation
|
|
protected:
|
|
//{{AFX_MSG(CAboutDlg)
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
|
{
|
|
//{{AFX_DATA_INIT(CAboutDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CAboutDlg)
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CAboutDlg)
|
|
// No message handlers
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CMainDlg dialog
|
|
|
|
CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CMainDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CMainDlg)
|
|
//}}AFX_DATA_INIT
|
|
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
m_bConnected = FALSE;
|
|
m_bLgsConnected = FALSE;
|
|
m_bFirstAlarm = TRUE;
|
|
m_bControlsInitiated = FALSE;
|
|
m_bLgsVoltageOk = TRUE;
|
|
}
|
|
|
|
void CMainDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CMainDlg)
|
|
DDX_Control(pDX, IDC_STATIC_STATUS_VOLTAGE, m_StaticStatusVoltage);
|
|
DDX_Control(pDX, IDOK, m_ButtonOk);
|
|
DDX_Control(pDX, IDC_STATIC_STATUS_TRANSFER, m_StaticStatusTransfer);
|
|
DDX_Control(pDX, IDC_STATIC_STATUS_LGS, m_StaticStatusLgs);
|
|
DDX_Control(pDX, IDC_STATIC_STATUS_CLIENT, m_StaticStatusClient);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CMainDlg)
|
|
ON_WM_SYSCOMMAND()
|
|
ON_WM_PAINT()
|
|
ON_WM_QUERYDRAGICON()
|
|
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
|
|
ON_WM_TIMER()
|
|
ON_WM_SIZE()
|
|
//}}AFX_MSG_MAP
|
|
ON_MESSAGE( LG_VIDEO_CLIENT_EVENT, OnLgVideoClientEvent )
|
|
ON_MESSAGE( LG_CAMERA_POSITION_CHANGED, OnLgCameraPositionChanged )
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CMainDlg message handlers
|
|
|
|
BOOL CMainDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// Add "About..." menu item to system menu.
|
|
|
|
// IDM_ABOUTBOX must be in the system command range.
|
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
if (pSysMenu != NULL)
|
|
{
|
|
CString strAboutMenu;
|
|
strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
if (!strAboutMenu.IsEmpty())
|
|
{
|
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
}
|
|
}
|
|
|
|
// Set the icon for this dialog. The framework does this automatically
|
|
// when the application's main window is not a dialog
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
// TODO: Add extra initialization here
|
|
|
|
|
|
HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( GetSafeHwnd(), GWL_HINSTANCE );
|
|
m_Skin.Load( "SkinClient\\skin.ini", hInstance );
|
|
|
|
CRect WindowRect;
|
|
WindowRect.SetRect( 0, 0, 1024, 768 );
|
|
MoveWindow( &WindowRect );
|
|
|
|
// ShowWindow( SW_SHOWMAXIMIZED );
|
|
|
|
m_Alarm.Create( _T("SingleIPIClient.wav") );
|
|
|
|
m_VideoClient.PtzLinkSP::Link( &m_DeviceClient );
|
|
m_VideoClient.LgsLinkSP::Link( &m_DeviceClient );
|
|
m_VideoClient.VideoLinkSP::Link( &m_DeviceClient );
|
|
m_VideoClient.ReportLinkSP::Link( &m_DeviceClient );
|
|
m_VideoClient.InfoLinkSP::Link( &m_DeviceClient );
|
|
|
|
m_DeviceClient.Create( GetSafeHwnd() );
|
|
|
|
CString strServerAddress = _T("192.117.174.60");
|
|
if( AfxGetApp() )
|
|
strServerAddress = AfxGetApp()->m_lpCmdLine;
|
|
if( strServerAddress == "" )
|
|
strServerAddress = _T("192.117.174.60");
|
|
|
|
m_VideoClient.Create( (LPCTSTR)strServerAddress, 2000 );
|
|
/*
|
|
m_DeviceClient.DoRemoteLgsBorder();
|
|
m_DeviceClient.DoRemoteReportList( REMOTE_CONTEXT_CLIENT, NULL, 0 );
|
|
m_DeviceClient.DoRemotePtzPosition( FALSE, 0,0,0 );
|
|
*/
|
|
// m_Tab.InsertItem( 0, "CONTROL" );
|
|
// m_Tab.InsertItem( 1, "REPORT" );
|
|
|
|
m_TabControlDlg.SetSkin( &m_Skin );
|
|
m_TabReportDlg.SetSkin( &m_Skin );
|
|
|
|
m_TabControlDlg.SetMainDlg( this );
|
|
m_TabControlDlg.Create( CTabControlDlg::IDD, this );
|
|
m_TabControlDlg.SetVideoQuality( 20 /*m_VideoClient.GetQuality()*/ );
|
|
|
|
m_TabReportDlg.SetMainDlg( this );
|
|
m_TabReportDlg.Create( CTabReportDlg::IDD, this );
|
|
|
|
/*
|
|
CRect FullRect;
|
|
m_Tab.GetClientRect( &FullRect );
|
|
CRect TabRect;
|
|
m_Tab.GetItemRect( 0, &TabRect );
|
|
|
|
FullRect.top = TabRect.bottom;
|
|
FullRect.DeflateRect( 2,2,2,2 );
|
|
|
|
m_TabControlDlg.MoveWindow( &FullRect );
|
|
m_TabReportDlg.MoveWindow( &FullRect );
|
|
*/
|
|
// m_Tab.SetCurSel(0);
|
|
m_TabControlDlg.ShowWindow( SW_SHOW );
|
|
|
|
m_TabControlDlg.EnableWindow( FALSE );
|
|
m_TabReportDlg.EnableWindow( FALSE );
|
|
|
|
m_Alarm.Beep();
|
|
|
|
SetTimer( 1, 300, NULL );
|
|
|
|
m_bControlsInitiated = TRUE;
|
|
|
|
UpdateControlPosition();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CMainDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
{
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
{
|
|
CAboutDlg dlgAbout;
|
|
dlgAbout.DoModal();
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnSysCommand(nID, lParam);
|
|
}
|
|
}
|
|
|
|
// If you add a minimize button to your dialog, you will need the code below
|
|
// to draw the icon. For MFC applications using the document/view model,
|
|
// this is automatically done for you by the framework.
|
|
|
|
void CMainDlg::OnPaint()
|
|
{
|
|
if (IsIconic())
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
|
|
|
// Center icon in client rectangle
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
|
|
// Draw the icon
|
|
dc.DrawIcon(x, y, m_hIcon);
|
|
|
|
return;
|
|
}
|
|
|
|
CDialog::OnPaint();
|
|
}
|
|
|
|
// The system calls this to obtain the cursor to display while the user drags
|
|
// the minimized window.
|
|
HCURSOR CMainDlg::OnQueryDragIcon()
|
|
{
|
|
return (HCURSOR) m_hIcon;
|
|
}
|
|
|
|
void CMainDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
// m_TabControlDlg.ShowWindow( (m_Tab.GetCurSel() == 0) ? m_TabControlDlg.SetFocus(), SW_SHOW : SW_HIDE );
|
|
// m_TabReportDlg.ShowWindow( (m_Tab.GetCurSel() == 1) ? m_TabReportDlg.SetFocus(), SW_SHOW : SW_HIDE );
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
LRESULT CMainDlg::OnLgVideoClientEvent( WPARAM wParam, LPARAM lParam )
|
|
{
|
|
CRect rect;
|
|
double dPan, dTilt, dZoom;
|
|
CDeviceClient::LGS_TARGET target;
|
|
BOOL bSet;
|
|
switch( wParam )
|
|
{
|
|
case VCE_VIDEO_SAMPLE:
|
|
// paint video frame
|
|
m_TabControlDlg.OnVideo( &m_DeviceClient.GetRemoteVideoDIB(), lParam );
|
|
|
|
// set current quality
|
|
// m_VideoClient.SetQuality( m_TabControlDlg.GetVideoQuality() );
|
|
break;
|
|
|
|
case VCE_CAMERA_PTZ:
|
|
if( m_DeviceClient.GetPosition( &bSet, &dPan, &dTilt, &dZoom ) )
|
|
{
|
|
if( bSet )
|
|
m_TabControlDlg.GetLocatorWnd()->ValidatePTZ( dPan, dTilt, dZoom );
|
|
// else
|
|
// m_TabControlDlg.GetLocatorWnd()->SetPTZ( dPan, dTilt, dZoom );
|
|
}
|
|
break;
|
|
|
|
case VCE_LGS_TARGET:
|
|
while( m_DeviceClient.GetTarget( target ) )
|
|
{
|
|
COLORREF color = RGB( 255, 255, 0 );
|
|
switch( target.bType )
|
|
{
|
|
case 'a':
|
|
color = RGB(255,255,0);
|
|
break;
|
|
case 'b':
|
|
color = RGB(255,255,255);
|
|
break;
|
|
case 'w':
|
|
color = RGB(255,0,0);
|
|
break;
|
|
}
|
|
|
|
m_TabControlDlg.GetLocatorWnd()->AddTarget( target.dAngle, target.dRange, color );
|
|
}
|
|
DoAlarm();
|
|
break;
|
|
|
|
case VCE_LGS_RESET:
|
|
m_TabControlDlg.m_ButtonClear.SendMessage( BM_CLICK );
|
|
m_TabControlDlg.m_ButtonReset.EnableWindow( TRUE );
|
|
break;
|
|
|
|
case VCE_LGS_CLEAR:
|
|
// m_TabControlDlg.m_ButtonClear.SendMessage( BM_CLICK );
|
|
if( !m_DeviceClient.DoRemoteLgsBorder() )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CMainDlg::OnLgVideoClientEvent"), _T("m_DeviceClient.DoRemoteLgsBorder 1 failed") );
|
|
}
|
|
break;
|
|
|
|
case VCE_LGS_SENSITIVITY:
|
|
switch( lParam )
|
|
{
|
|
case LG_TCP_PACKET_LGS::LGS_SENSITIVITY_LOW:
|
|
m_TabControlDlg.m_RadioSensitivity = 0;
|
|
m_TabControlDlg.UpdateData( FALSE );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_SENSITIVITY_MEDIUM:
|
|
m_TabControlDlg.m_RadioSensitivity = 1;
|
|
m_TabControlDlg.UpdateData( FALSE );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_SENSITIVITY_HIGH:
|
|
m_TabControlDlg.m_RadioSensitivity = 2;
|
|
m_TabControlDlg.UpdateData( FALSE );
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case VCE_LGS_HIDDEN_ON:
|
|
m_TabControlDlg.m_CheckHidden1.SetCheck( HIWORD( lParam ) & LG_TCP_PACKET_LGS::LGS_HIDDEN_ON_ZONE_1 );
|
|
m_TabControlDlg.m_CheckHidden2.SetCheck( HIWORD( lParam ) & LG_TCP_PACKET_LGS::LGS_HIDDEN_ON_ZONE_2 );
|
|
m_TabControlDlg.m_CheckHidden3.SetCheck( HIWORD( lParam ) & LG_TCP_PACKET_LGS::LGS_HIDDEN_ON_ZONE_3 );
|
|
m_TabControlDlg.m_CheckHidden4.SetCheck( HIWORD( lParam ) & LG_TCP_PACKET_LGS::LGS_HIDDEN_ON_ZONE_4 );
|
|
if( !m_DeviceClient.DoRemoteLgsBorder() )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CMainDlg::OnLgVideoClientEvent"), _T("m_DeviceClient.DoRemoteLgsBorder 2 failed") );
|
|
}
|
|
break;
|
|
|
|
case VCE_LGS_BORDER:
|
|
m_TabControlDlg.GetLocatorWnd()->SetBackgroundDIB( &m_DeviceClient.GetRemoteBackgroundDIB() );
|
|
break;
|
|
|
|
case VCE_REPORT_LIST:
|
|
m_TabReportDlg.SetReportList( m_DeviceClient.GetReportListBuffer(), m_DeviceClient.GetReportListSize() );
|
|
break;
|
|
|
|
case VCE_REPORT_FILE:
|
|
m_TabReportDlg.SetReportFile( m_DeviceClient.GetReportFileBuffer(), m_DeviceClient.GetReportFileSize() );
|
|
break;
|
|
|
|
case VCE_INFO_CONNECT:
|
|
m_bConnected = lParam;
|
|
if( !m_bConnected )
|
|
DoAlarm();
|
|
|
|
m_TabControlDlg.OnConnect( lParam );
|
|
m_TabControlDlg.EnableWindow( lParam );
|
|
m_TabReportDlg.EnableWindow( lParam );
|
|
break;
|
|
|
|
case VCE_LGS_CONNECT:
|
|
m_bLgsConnected = lParam;
|
|
if( !m_bLgsConnected )
|
|
DoAlarm();
|
|
break;
|
|
|
|
case VCE_LGS_VOLTAGE:
|
|
m_bLgsVoltageOk = lParam;
|
|
if( !m_bLgsVoltageOk )
|
|
DoAlarm();
|
|
break;
|
|
|
|
case VCE_PTZ_IRIS:
|
|
m_TabControlDlg.SetIris( lParam );
|
|
break;
|
|
|
|
case VCE_TRANSFER_INFO:
|
|
{
|
|
CString str;
|
|
LARGE_INTEGER liTX, liRX;
|
|
m_DeviceClient.GetTransferInfo( &liTX, &liRX );
|
|
str.Format( "TX:%I64d, RX:%I64d", liTX.QuadPart, liRX.QuadPart );
|
|
m_StaticStatusTransfer.SetWindowText( str );
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
LRESULT CMainDlg::OnLgCameraPositionChanged( WPARAM wParam, LPARAM lParam )
|
|
{
|
|
// update network position
|
|
m_DeviceClient.SetPosition( TRUE, m_TabControlDlg.GetLocatorWnd()->GetPTZ().dPan, m_TabControlDlg.GetLocatorWnd()->GetPTZ().dTilt, m_TabControlDlg.GetLocatorWnd()->GetPTZ().dZoom );
|
|
return 0;
|
|
}
|
|
|
|
|
|
BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
switch( pMsg->message )
|
|
{
|
|
case WM_KEYDOWN:
|
|
// if( m_Tab.GetCurSel() == 0 )
|
|
switch( pMsg->wParam )
|
|
{
|
|
case VK_UP: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_UP, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_DOWN: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_DOWN, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_LEFT: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_LEFT, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_RIGHT: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_RIGHT, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_HOME:
|
|
case VK_ADD: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_TELE, BM_SETSTATE, TRUE ); return TRUE;
|
|
case VK_END:
|
|
case VK_SUBTRACT: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_WIDE, BM_SETSTATE, TRUE ); return TRUE;
|
|
}
|
|
if( pMsg->wParam == VK_SPACE )
|
|
AlarmStop();
|
|
break;
|
|
case WM_KEYUP:
|
|
// if( m_Tab.GetCurSel() == 0 )
|
|
switch( pMsg->wParam )
|
|
{
|
|
case VK_UP: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_UP, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_DOWN: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_DOWN, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_LEFT: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_LEFT, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_RIGHT: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_RIGHT, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_HOME:
|
|
case VK_ADD: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_TELE, BM_SETSTATE, FALSE ); return TRUE;
|
|
case VK_END:
|
|
case VK_SUBTRACT: m_TabControlDlg.SendDlgItemMessage( IDC_BUTTON_WIDE, BM_SETSTATE, FALSE ); return TRUE;
|
|
}
|
|
break;
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void CMainDlg::OnTimer(UINT nIDEvent)
|
|
{
|
|
LPCTSTR pClientText, pLgsText, pVoltageText;
|
|
pClientText = pLgsText = pVoltageText = _T("");
|
|
BOOL bVoltageShow = FALSE;
|
|
if( m_bConnected )
|
|
{
|
|
pClientText = _T("CLIENT CONNECTED");
|
|
|
|
if( m_bLgsConnected )
|
|
{
|
|
pLgsText = _T("LGS CONNECTED");
|
|
|
|
if( !m_bLgsVoltageOk )
|
|
{
|
|
bVoltageShow = TRUE;
|
|
|
|
if( m_nConnect++ % 2 )
|
|
pVoltageText = _T("LOW VOLTAGE");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( m_nConnect++ % 2 )
|
|
pLgsText = _T("LGS DISCONNECTED");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if( m_nConnect++ % 2 )
|
|
pClientText = _T( "CLIENT DISCONNECTED" );
|
|
|
|
pLgsText = _T( "LGS STATE UNKNOWN" );
|
|
}
|
|
|
|
m_StaticStatusClient.SetWindowText( pClientText );
|
|
|
|
m_StaticStatusLgs.SetWindowText( pLgsText );
|
|
|
|
if( m_StaticStatusVoltage.IsWindowVisible() != bVoltageShow )
|
|
m_StaticStatusVoltage.ShowWindow( bVoltageShow ? SW_SHOW : SW_HIDE );
|
|
m_StaticStatusVoltage.SetWindowText( pVoltageText );
|
|
|
|
// ask about transfer rate info
|
|
if( !m_DeviceClient.DoRemoteInfoTransfer() )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CMainDlg::OnTimer"), _T("m_DeviceClient.DoRemoteInfoTransfer failed") );
|
|
}
|
|
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
void CMainDlg::DoAlarm()
|
|
{
|
|
if( m_bFirstAlarm )
|
|
m_Alarm.Start();
|
|
else
|
|
m_Alarm.Beep();
|
|
}
|
|
|
|
void CMainDlg::AlarmMute( BOOL bMute )
|
|
{
|
|
m_Alarm.Enable( bMute );
|
|
AlarmStop();
|
|
}
|
|
|
|
void CMainDlg::AlarmReset()
|
|
{
|
|
m_bFirstAlarm = TRUE;
|
|
m_Alarm.Stop();
|
|
}
|
|
|
|
void CMainDlg::AlarmStop()
|
|
{
|
|
m_bFirstAlarm = FALSE;
|
|
m_Alarm.Stop();
|
|
}
|
|
|
|
void CMainDlg::UpdateControlPosition()
|
|
{
|
|
if( !m_bControlsInitiated )
|
|
return;
|
|
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
m_TabControlDlg.MoveWindow( &rect );
|
|
m_TabReportDlg.MoveWindow( &rect );
|
|
|
|
// space between controls
|
|
INT nSpace = 5;
|
|
|
|
// store client rect of control
|
|
CRect ClientRect;
|
|
GetClientRect( &ClientRect );
|
|
|
|
// set position of tab control
|
|
CRect TabRect;
|
|
TabRect.SetRect( ClientRect.left + nSpace, ClientRect.top + nSpace,
|
|
ClientRect.right - nSpace, ClientRect.bottom - 2 * nSpace - 20 );
|
|
// m_Tab.MoveWindow( &TabRect );
|
|
|
|
// set position of button "Exit" (Ok)
|
|
CRect ButtonOkRect;
|
|
ButtonOkRect.SetRect( ClientRect.right - 100 - nSpace, TabRect.bottom + nSpace,
|
|
ClientRect.right - nSpace, ClientRect.bottom - nSpace );
|
|
m_ButtonOk.MoveWindow( &ButtonOkRect );
|
|
|
|
// calculate width of status windows
|
|
INT nWidth = ( ButtonOkRect.left - TabRect.left - 2 * nSpace ) / 3;
|
|
|
|
// set position of client's status
|
|
CRect StatisClientRect;
|
|
StatisClientRect.SetRect( ClientRect.right - nSpace - 200, ClientRect.top + nSpace,
|
|
ClientRect.right - nSpace, ClientRect.top + nSpace + 18 );
|
|
m_StaticStatusClient.MoveWindow( &StatisClientRect );
|
|
|
|
// set position of lgs's status
|
|
CRect StatisLgsRect;
|
|
StatisLgsRect.SetRect( StatisClientRect.left, StatisClientRect.bottom,
|
|
StatisClientRect.right, StatisClientRect.bottom + 18 );
|
|
m_StaticStatusLgs.MoveWindow( &StatisLgsRect );
|
|
|
|
// set position of transfer's status
|
|
CRect StatisTransferRect;
|
|
StatisTransferRect.SetRect(StatisLgsRect.left, StatisLgsRect.bottom,
|
|
StatisLgsRect.right, StatisLgsRect.bottom + 18 );
|
|
m_StaticStatusTransfer.MoveWindow( &StatisTransferRect );
|
|
|
|
CRect StatisVoltageRect;
|
|
StatisVoltageRect.SetRect( StatisLgsRect.left - StatisLgsRect.Width(), StatisLgsRect.top,
|
|
StatisLgsRect.left, StatisLgsRect.bottom );
|
|
m_StaticStatusVoltage.MoveWindow( &StatisVoltageRect );
|
|
m_StaticStatusVoltage.ShowWindow( SW_HIDE );
|
|
/*
|
|
// set position of controls in tab control
|
|
CRect TabClientRect;
|
|
m_Tab.GetClientRect( &TabClientRect );
|
|
CRect TabTabRect;
|
|
m_Tab.GetItemRect( 0, &TabTabRect );
|
|
TabClientRect.top = TabTabRect.bottom;
|
|
TabClientRect.DeflateRect( 2,2,2,2 );
|
|
m_TabControlDlg.MoveWindow( &TabClientRect );
|
|
m_TabReportDlg.MoveWindow( &TabClientRect );
|
|
*/
|
|
|
|
// update controls itself
|
|
if( m_TabControlDlg.GetSafeHwnd() )
|
|
m_TabControlDlg.UpdateControlPosition();
|
|
if( m_TabReportDlg.GetSafeHwnd() )
|
|
m_TabReportDlg.UpdateControlPosition();
|
|
|
|
}
|
|
|
|
void CMainDlg::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDialog::OnSize(nType, cx, cy);
|
|
|
|
UpdateControlPosition();
|
|
}
|
|
|
|
void CMainDlg::ShowReport(BOOL bReport)
|
|
{
|
|
m_TabControlDlg.ShowWindow( (!bReport) ? m_TabControlDlg.SetFocus(), SW_SHOW : SW_HIDE );
|
|
m_TabReportDlg.ShowWindow( (bReport) ? m_TabReportDlg.SetFocus(), SW_SHOW : SW_HIDE );
|
|
}
|