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.

247 lines
5.6 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: ServiceDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ServiceDlg.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "ServiceDlg.h"
  16. #include "Resource.h"
  17. #include "Application.h"
  18. #include "..\LgLib\Version.h"
  19. CServiceDlg::CServiceDlg()
  20. {
  21. m_hWnd = NULL;
  22. m_pApplication = NULL;
  23. memset( m_hButtonBitmaps, 0, sizeof(m_hButtonBitmaps) );
  24. }
  25. CServiceDlg::~CServiceDlg()
  26. {
  27. Destroy();
  28. }
  29. BOOL CServiceDlg::Create( CApplication* pApplication, HWND hParent, INT x, INT y, INT cx, INT cy )
  30. {
  31. m_pApplication = pApplication;
  32. HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE );
  33. m_hWnd = ::CreateDialogParam( hInstance,
  34. MAKEINTRESOURCE(IDD_SERVICE_DLG), hParent,
  35. WindowProc_, (LPARAM)this );
  36. if( !m_hWnd )
  37. return FALSE;
  38. // store items position
  39. m_DialogItemsPosition.Create( m_hWnd );
  40. // move window to position
  41. ::MoveWindow( m_hWnd, x, y, cx, cy, TRUE );
  42. ::ShowWindow( m_hWnd, SW_HIDE );
  43. ::UpdateWindow( m_hWnd );
  44. return TRUE;
  45. }
  46. void CServiceDlg::Destroy()
  47. {
  48. if( m_hWnd )
  49. ::DestroyWindow( m_hWnd );
  50. }
  51. void CServiceDlg::ShowWindow( UINT nShow )
  52. {
  53. ::ShowWindow( m_hWnd, nShow );
  54. }
  55. BOOL CALLBACK CServiceDlg::WindowProc_( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  56. {
  57. switch( uMsg )
  58. {
  59. case WM_INITDIALOG:
  60. ::SetWindowLong( hWnd, GWL_USERDATA, lParam );
  61. break;
  62. }
  63. CServiceDlg *pThis = (CServiceDlg*)::GetWindowLong( hWnd, GWL_USERDATA );
  64. if( pThis )
  65. return pThis->WindowProc( uMsg, wParam, lParam );
  66. return TRUE;
  67. }
  68. BOOL CServiceDlg::WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam )
  69. {
  70. switch( uMsg )
  71. {
  72. case WM_DESTROY:
  73. return OnDestroy( wParam, lParam );
  74. case WM_COMMAND:
  75. return OnCommand( wParam, lParam );
  76. case WM_INITDIALOG:
  77. return OnInitDialog( wParam, lParam );
  78. case WM_MOVE:
  79. return OnMove( wParam, lParam );
  80. case WM_SIZE:
  81. return OnSize( wParam, lParam );
  82. case WM_PAINT:
  83. return OnPaint( wParam, lParam );
  84. case WM_ERASEBKGND:
  85. return OnEraseBackground( wParam, lParam );
  86. }
  87. return 0;
  88. }
  89. LRESULT CServiceDlg::OnInitDialog( WPARAM, LPARAM )
  90. {
  91. return 0;
  92. }
  93. LRESULT CServiceDlg::OnSize( WPARAM, LPARAM )
  94. {
  95. m_DialogItemsPosition.Center();
  96. return 1;
  97. }
  98. LRESULT CServiceDlg::OnMove( WPARAM, LPARAM )
  99. {
  100. m_DialogItemsPosition.Center();
  101. return 1;
  102. }
  103. LRESULT CServiceDlg::OnPaint( WPARAM, LPARAM )
  104. {
  105. PAINTSTRUCT ps;
  106. HDC hDC = ::BeginPaint( m_hWnd, &ps );
  107. OnDraw( hDC );
  108. ::EndPaint( m_hWnd, &ps );
  109. return 1;
  110. }
  111. LRESULT CServiceDlg::OnEraseBackground( WPARAM, LPARAM )
  112. {
  113. return 1;
  114. }
  115. void CServiceDlg::OnDraw( HDC hDC )
  116. {
  117. HBITMAP hMemBitmap = m_pApplication->GetSkin().hMainService;
  118. if( !hMemBitmap )
  119. return;
  120. DIBSECTION DibSection;
  121. if( !GetObject( hMemBitmap, sizeof(DibSection), &DibSection ) )
  122. return;
  123. // draw background
  124. HDC hMemDC = ::CreateCompatibleDC( hDC );
  125. HBITMAP hBitmap = (HBITMAP)::SelectObject( hMemDC, hMemBitmap );
  126. ::BitBlt( hDC, 0, 0, DibSection.dsBm.bmWidth, DibSection.dsBm.bmHeight, hMemDC, 0, 0, SRCCOPY );
  127. ::SelectObject( hMemDC, hBitmap );
  128. ::DeleteDC( hDC );
  129. }
  130. LRESULT CServiceDlg::OnDestroy( WPARAM wParam, LPARAM lParam )
  131. {
  132. // delete bitmaps
  133. for( INT i = 0; i < sizeof(m_hButtonBitmaps)/sizeof(m_hButtonBitmaps[0]); i++ )
  134. {
  135. if( m_hButtonBitmaps[i] )
  136. {
  137. ::DeleteObject( m_hButtonBitmaps[i] );
  138. m_hButtonBitmaps[i] = NULL;
  139. }
  140. }
  141. // destroy itself
  142. HWND hWnd = m_hWnd;
  143. m_hWnd = NULL;
  144. return TRUE;
  145. }
  146. LRESULT CServiceDlg::OnCommand( WPARAM wParam, LPARAM )
  147. {
  148. UINT nCtrlId = LOWORD( wParam );
  149. switch( nCtrlId )
  150. {
  151. case IDC_CHECK_SETUP:
  152. if(HIWORD(wParam) == BN_CLICKED)
  153. m_pApplication->ChangeSetupMode();
  154. break;
  155. case IDC_BUTTON_PTZ:
  156. if(HIWORD(wParam) == BN_CLICKED)
  157. m_pApplication->SetPtz();
  158. break;
  159. case IDC_CHECK_EDIT:
  160. if(HIWORD(wParam) == BN_CLICKED)
  161. m_pApplication->ChangeEditMode();
  162. break;
  163. case IDC_BUTTON_OPTIONS:
  164. if(HIWORD(wParam) == BN_CLICKED)
  165. m_pApplication->OptionsDlg();
  166. break;
  167. case IDC_CHECK_SHOW_TARGETS: // 11/05/2001 Capturing video
  168. if(HIWORD(wParam) == BN_CLICKED)
  169. { // 13/05/2001
  170. BOOL fChecked = SendDlgItemMessage(m_hWnd, IDC_CHECK_SHOW_TARGETS, BM_GETCHECK, 0, 0) != BST_CHECKED;
  171. SetDlgItemText(m_hWnd, IDC_CHECK_SHOW_TARGETS,
  172. fChecked ? _T("Live") : _T("Record"));
  173. m_pApplication->SetShowNormal(fChecked);
  174. }
  175. break;
  176. }
  177. return TRUE;
  178. }
  179. void CServiceDlg::SetSetupCheck(BOOL fCheck)
  180. {
  181. ::SendDlgItemMessage(m_hWnd, IDC_CHECK_SETUP, BM_SETCHECK, fCheck, 0);
  182. }
  183. void CServiceDlg::SetEditCheck(BOOL fCheck)
  184. {
  185. ::SendDlgItemMessage(m_hWnd, IDC_CHECK_EDIT, BM_SETCHECK, fCheck, 0);
  186. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON_REPORT), !fCheck);
  187. }
  188. void CServiceDlg::EnableCameraShift(BOOL fEnable)
  189. {
  190. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON_PTZ), fEnable);
  191. }
  192. void CServiceDlg::EnableEditor(BOOL fEnable)
  193. {
  194. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_EDIT), fEnable);
  195. // ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_FENCE), fEnable);
  196. }
  197. void CServiceDlg::EnableOptions(BOOL fEnable)
  198. {
  199. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON_OPTIONS), fEnable);
  200. }
  201. void CServiceDlg::SetShowNormalCheck(BOOL fCheck)
  202. {
  203. ::SendDlgItemMessage(m_hWnd, IDC_CHECK_SHOW_TARGETS, BM_SETCHECK, fCheck, 0);
  204. }