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.
247 lines
5.6 KiB
247 lines
5.6 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: ServiceDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of ServiceDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "ServiceDlg.h"
|
|
#include "Resource.h"
|
|
#include "Application.h"
|
|
#include "..\LgLib\Version.h"
|
|
|
|
CServiceDlg::CServiceDlg()
|
|
{
|
|
m_hWnd = NULL;
|
|
|
|
m_pApplication = NULL;
|
|
|
|
memset( m_hButtonBitmaps, 0, sizeof(m_hButtonBitmaps) );
|
|
}
|
|
|
|
CServiceDlg::~CServiceDlg()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
BOOL CServiceDlg::Create( CApplication* pApplication, HWND hParent, INT x, INT y, INT cx, INT cy )
|
|
{
|
|
m_pApplication = pApplication;
|
|
|
|
HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE );
|
|
|
|
m_hWnd = ::CreateDialogParam( hInstance,
|
|
MAKEINTRESOURCE(IDD_SERVICE_DLG), hParent,
|
|
WindowProc_, (LPARAM)this );
|
|
if( !m_hWnd )
|
|
return FALSE;
|
|
|
|
// store items position
|
|
m_DialogItemsPosition.Create( m_hWnd );
|
|
|
|
// move window to position
|
|
::MoveWindow( m_hWnd, x, y, cx, cy, TRUE );
|
|
|
|
::ShowWindow( m_hWnd, SW_HIDE );
|
|
::UpdateWindow( m_hWnd );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CServiceDlg::Destroy()
|
|
{
|
|
if( m_hWnd )
|
|
::DestroyWindow( m_hWnd );
|
|
}
|
|
|
|
void CServiceDlg::ShowWindow( UINT nShow )
|
|
{
|
|
::ShowWindow( m_hWnd, nShow );
|
|
}
|
|
|
|
|
|
BOOL CALLBACK CServiceDlg::WindowProc_( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
{
|
|
switch( uMsg )
|
|
{
|
|
case WM_INITDIALOG:
|
|
::SetWindowLong( hWnd, GWL_USERDATA, lParam );
|
|
break;
|
|
}
|
|
|
|
CServiceDlg *pThis = (CServiceDlg*)::GetWindowLong( hWnd, GWL_USERDATA );
|
|
if( pThis )
|
|
return pThis->WindowProc( uMsg, wParam, lParam );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CServiceDlg::WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
{
|
|
switch( uMsg )
|
|
{
|
|
case WM_DESTROY:
|
|
return OnDestroy( wParam, lParam );
|
|
case WM_COMMAND:
|
|
return OnCommand( wParam, lParam );
|
|
case WM_INITDIALOG:
|
|
return OnInitDialog( wParam, lParam );
|
|
case WM_MOVE:
|
|
return OnMove( wParam, lParam );
|
|
case WM_SIZE:
|
|
return OnSize( wParam, lParam );
|
|
case WM_PAINT:
|
|
return OnPaint( wParam, lParam );
|
|
case WM_ERASEBKGND:
|
|
return OnEraseBackground( wParam, lParam );
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnInitDialog( WPARAM, LPARAM )
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnSize( WPARAM, LPARAM )
|
|
{
|
|
m_DialogItemsPosition.Center();
|
|
return 1;
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnMove( WPARAM, LPARAM )
|
|
{
|
|
m_DialogItemsPosition.Center();
|
|
return 1;
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnPaint( WPARAM, LPARAM )
|
|
{
|
|
PAINTSTRUCT ps;
|
|
HDC hDC = ::BeginPaint( m_hWnd, &ps );
|
|
OnDraw( hDC );
|
|
::EndPaint( m_hWnd, &ps );
|
|
return 1;
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnEraseBackground( WPARAM, LPARAM )
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
void CServiceDlg::OnDraw( HDC hDC )
|
|
{
|
|
HBITMAP hMemBitmap = m_pApplication->GetSkin().hMainService;
|
|
if( !hMemBitmap )
|
|
return;
|
|
|
|
DIBSECTION DibSection;
|
|
if( !GetObject( hMemBitmap, sizeof(DibSection), &DibSection ) )
|
|
return;
|
|
|
|
// draw background
|
|
HDC hMemDC = ::CreateCompatibleDC( hDC );
|
|
HBITMAP hBitmap = (HBITMAP)::SelectObject( hMemDC, hMemBitmap );
|
|
::BitBlt( hDC, 0, 0, DibSection.dsBm.bmWidth, DibSection.dsBm.bmHeight, hMemDC, 0, 0, SRCCOPY );
|
|
::SelectObject( hMemDC, hBitmap );
|
|
::DeleteDC( hDC );
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnDestroy( WPARAM wParam, LPARAM lParam )
|
|
{
|
|
// delete bitmaps
|
|
for( INT i = 0; i < sizeof(m_hButtonBitmaps)/sizeof(m_hButtonBitmaps[0]); i++ )
|
|
{
|
|
if( m_hButtonBitmaps[i] )
|
|
{
|
|
::DeleteObject( m_hButtonBitmaps[i] );
|
|
m_hButtonBitmaps[i] = NULL;
|
|
}
|
|
}
|
|
|
|
// destroy itself
|
|
HWND hWnd = m_hWnd;
|
|
m_hWnd = NULL;
|
|
return TRUE;
|
|
}
|
|
|
|
LRESULT CServiceDlg::OnCommand( WPARAM wParam, LPARAM )
|
|
{
|
|
UINT nCtrlId = LOWORD( wParam );
|
|
|
|
switch( nCtrlId )
|
|
{
|
|
case IDC_CHECK_SETUP:
|
|
if(HIWORD(wParam) == BN_CLICKED)
|
|
m_pApplication->ChangeSetupMode();
|
|
break;
|
|
|
|
case IDC_BUTTON_PTZ:
|
|
if(HIWORD(wParam) == BN_CLICKED)
|
|
m_pApplication->SetPtz();
|
|
break;
|
|
|
|
case IDC_CHECK_EDIT:
|
|
if(HIWORD(wParam) == BN_CLICKED)
|
|
m_pApplication->ChangeEditMode();
|
|
break;
|
|
|
|
case IDC_BUTTON_OPTIONS:
|
|
if(HIWORD(wParam) == BN_CLICKED)
|
|
m_pApplication->OptionsDlg();
|
|
break;
|
|
case IDC_CHECK_SHOW_TARGETS: // 11/05/2001 Capturing video
|
|
if(HIWORD(wParam) == BN_CLICKED)
|
|
{ // 13/05/2001
|
|
BOOL fChecked = SendDlgItemMessage(m_hWnd, IDC_CHECK_SHOW_TARGETS, BM_GETCHECK, 0, 0) != BST_CHECKED;
|
|
|
|
SetDlgItemText(m_hWnd, IDC_CHECK_SHOW_TARGETS,
|
|
fChecked ? _T("Live") : _T("Record"));
|
|
|
|
m_pApplication->SetShowNormal(fChecked);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CServiceDlg::SetSetupCheck(BOOL fCheck)
|
|
{
|
|
::SendDlgItemMessage(m_hWnd, IDC_CHECK_SETUP, BM_SETCHECK, fCheck, 0);
|
|
}
|
|
|
|
void CServiceDlg::SetEditCheck(BOOL fCheck)
|
|
{
|
|
::SendDlgItemMessage(m_hWnd, IDC_CHECK_EDIT, BM_SETCHECK, fCheck, 0);
|
|
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON_REPORT), !fCheck);
|
|
}
|
|
|
|
void CServiceDlg::EnableCameraShift(BOOL fEnable)
|
|
{
|
|
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON_PTZ), fEnable);
|
|
}
|
|
|
|
void CServiceDlg::EnableEditor(BOOL fEnable)
|
|
{
|
|
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_EDIT), fEnable);
|
|
// ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_FENCE), fEnable);
|
|
}
|
|
|
|
void CServiceDlg::EnableOptions(BOOL fEnable)
|
|
{
|
|
::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON_OPTIONS), fEnable);
|
|
}
|
|
|
|
void CServiceDlg::SetShowNormalCheck(BOOL fCheck)
|
|
{
|
|
::SendDlgItemMessage(m_hWnd, IDC_CHECK_SHOW_TARGETS, BM_SETCHECK, fCheck, 0);
|
|
}
|