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.

236 lines
7.2 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: SetupFixedVideoDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of SetupFixedVideoDlg.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "resource.h"
  16. #include "SetupFixedVideoDlg.h"
  17. #include "..\LgLib\Video\LgDirectShowVideoInputEnum.h"
  18. #include "..\LgLib\Version.h"
  19. CSetupFixedVideoDlg::CSetupFixedVideoDlg()
  20. {
  21. }
  22. CSetupFixedVideoDlg::~CSetupFixedVideoDlg()
  23. {
  24. }
  25. BOOL CSetupFixedVideoDlg::DoModal( PPROFILE_DATA pRofileData, CLocatorRegionArray *pRegionArray, HBITMAP hBackground, HWND hParent )
  26. {
  27. // get hinstance handle
  28. HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE );
  29. // store data
  30. m_Data = *pRofileData;
  31. m_RegionArray = *pRegionArray;
  32. m_hBackground = hBackground;
  33. // call edit dialog
  34. if( CGenericWnd::DoModal( hInstance, (LPCTSTR)IDD_SETUP_FIXED_VIDEO_DLG, hParent ) == IDOK )
  35. {
  36. // update data
  37. *pRofileData = m_Data;
  38. *pRegionArray = m_RegionArray;
  39. return TRUE;
  40. }
  41. return FALSE;
  42. }
  43. LRESULT CSetupFixedVideoDlg::OnCommand( WPARAM wParam, LPARAM )
  44. {
  45. UINT nCtrlId = LOWORD( wParam );
  46. switch( nCtrlId )
  47. {
  48. case IDOK:
  49. if( HIWORD(wParam) == BN_CLICKED )
  50. OnButtonOk();
  51. break;
  52. case IDCANCEL:
  53. if( HIWORD(wParam) == BN_CLICKED )
  54. EndDialog( IDCANCEL );
  55. break;
  56. case IDC_CHECK_FIXED_VIDEO_ENABLE:
  57. if( HIWORD(wParam) == BN_CLICKED )
  58. OnCheckEnable();
  59. break;
  60. case IDC_CHECK_EDIT_LINE:
  61. if( HIWORD(wParam) == BN_CLICKED )
  62. OnCheckEditLine();
  63. break;
  64. case IDC_CHECK_EDIT_POINT:
  65. if( HIWORD(wParam) == BN_CLICKED )
  66. OnCheckEditPoint();
  67. break;
  68. case IDC_BUTTON_CLEAR:
  69. OnButtonClear();
  70. }
  71. return TRUE;
  72. }
  73. LRESULT CSetupFixedVideoDlg::OnInitDialog( WPARAM, LPARAM )
  74. {
  75. // create locator window
  76. RECT rect;
  77. ::GetClientRect( GetDlgItem( IDC_STATIC_LOCATOR ), &rect );
  78. ::MapWindowPoints( GetDlgItem( IDC_STATIC_LOCATOR ), GetSafeHwnd(), (LPPOINT)&rect, 2 );
  79. m_LocatorWnd.Create( GetSafeHwnd(), rect.left, rect.top,
  80. rect.right - rect.left, rect.bottom - rect.top );
  81. // get hinstance handle
  82. HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( GetSafeHwnd(), GWL_HINSTANCE );
  83. // set locator background
  84. m_LocatorWnd.SetBackground( m_hBackground );
  85. // set region array
  86. m_LocatorWnd.SetRegionArray( &m_RegionArray );
  87. // adjust controls
  88. ::CheckRadioButton( GetSafeHwnd(), IDC_RADIO_FIXED_VIDEO_INPUT1, IDC_RADIO_FIXED_VIDEO_INPUT4, m_Data.FixedVideoInput + IDC_RADIO_FIXED_VIDEO_INPUT1 );
  89. // ::CheckRadioButton( GetSafeHwnd(), IDC_RADIO_FIXED_VIDEO_DEVICE1, IDC_RADIO_FIXED_VIDEO_DEVICE4, m_Data.FixedVideoDevice + IDC_RADIO_FIXED_VIDEO_DEVICE1 );
  90. ::SendDlgItemMessage( GetSafeHwnd(), IDC_COMBO_VIDEO_DEVICE, CB_RESETCONTENT, 0, 0 );
  91. CLgDirectShowVideoInputEnum vie;
  92. if( vie.Create() )
  93. {
  94. for( INT i = 0; i < vie.GetVideoInputDeviceCount(); i++ )
  95. {
  96. CLgDirectShowVideoInputEnum::DSVID_INFO DeviceInfo;
  97. if( vie.GetVideoInputDeviceInfo( i, &DeviceInfo ) )
  98. ::SendDlgItemMessage( GetSafeHwnd(), IDC_COMBO_VIDEO_DEVICE, CB_ADDSTRING, 0, (LPARAM)DeviceInfo.pFrendlyName );
  99. }
  100. ::SendDlgItemMessage( GetSafeHwnd(), IDC_COMBO_VIDEO_DEVICE, CB_SETCURSEL, m_Data.FixedVideoDevice, 0 );
  101. }
  102. ::CheckRadioButton( GetSafeHwnd(), IDC_RADIO_FIXED_VIDEO_PAL, IDC_RADIO_FIXED_VIDEO_NTSC, m_Data.FixedVideoStandart + IDC_RADIO_FIXED_VIDEO_PAL );
  103. ::SendDlgItemMessage( GetSafeHwnd(), IDC_CHECK_FIXED_VIDEO_ENABLE, BM_SETCHECK, m_Data.FixedVideoEnable, 0 );
  104. // update dynamic controls
  105. OnCheckEnable();
  106. OnCheckEditLine();
  107. OnCheckEditPoint();
  108. return FALSE;
  109. }
  110. void CSetupFixedVideoDlg::OnButtonOk()
  111. {
  112. // fixed video parameters
  113. for( INT i = IDC_RADIO_FIXED_VIDEO_INPUT1; i <= IDC_RADIO_FIXED_VIDEO_INPUT4; i++ )
  114. {
  115. if( SendDlgItemMessage( i, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  116. {
  117. m_Data.FixedVideoInput = i - IDC_RADIO_FIXED_VIDEO_INPUT1;
  118. break;
  119. }
  120. }
  121. /*
  122. for( i = IDC_RADIO_FIXED_VIDEO_DEVICE1; i <= IDC_RADIO_FIXED_VIDEO_DEVICE4; i++ )
  123. {
  124. if( SendDlgItemMessage( i, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  125. {
  126. m_Data.FixedVideoDevice = i - IDC_RADIO_FIXED_VIDEO_DEVICE1;
  127. break;
  128. }
  129. }
  130. */
  131. m_Data.FixedVideoDevice = ::SendDlgItemMessage( GetSafeHwnd(), IDC_COMBO_VIDEO_DEVICE, CB_GETCURSEL, 0, 0 );
  132. for( i = IDC_RADIO_FIXED_VIDEO_PAL; i <= IDC_RADIO_FIXED_VIDEO_NTSC; i++ )
  133. {
  134. if( SendDlgItemMessage( i, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  135. {
  136. m_Data.FixedVideoStandart = i - IDC_RADIO_FIXED_VIDEO_PAL;
  137. break;
  138. }
  139. }
  140. m_Data.FixedVideoEnable = SendDlgItemMessage( IDC_CHECK_FIXED_VIDEO_ENABLE, BM_GETCHECK, 0, 0 );
  141. m_RegionArray = m_LocatorWnd.GetRegionArray();
  142. EndDialog( IDOK );
  143. }
  144. void CSetupFixedVideoDlg::OnButtonClear()
  145. {
  146. m_LocatorWnd.ClearRegions();
  147. }
  148. void CSetupFixedVideoDlg::OnCheckEnable()
  149. {
  150. // get enable flag
  151. BOOL bEnable = SendDlgItemMessage( IDC_CHECK_FIXED_VIDEO_ENABLE, BM_GETCHECK, 0, 0 );
  152. // enable controls according to enable flag
  153. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_DEVICE1 ), bEnable );
  154. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_DEVICE2 ), bEnable );
  155. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_DEVICE3 ), bEnable );
  156. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_DEVICE4 ), bEnable );
  157. ::EnableWindow( GetDlgItem( IDC_COMBO_VIDEO_DEVICE ), bEnable );
  158. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_INPUT1 ), bEnable );
  159. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_INPUT2 ), bEnable );
  160. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_INPUT3 ), bEnable );
  161. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_INPUT4 ), bEnable );
  162. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_PAL ), bEnable );
  163. ::EnableWindow( GetDlgItem( IDC_RADIO_FIXED_VIDEO_NTSC ), bEnable );
  164. ::EnableWindow( GetDlgItem( IDC_CHECK_EDIT_LINE ), bEnable );
  165. ::EnableWindow( GetDlgItem( IDC_CHECK_EDIT_POINT ), bEnable );
  166. // check edit state
  167. if( !bEnable )
  168. {
  169. // go out from edit mode
  170. if( SendDlgItemMessage( IDC_CHECK_EDIT, BM_GETCHECK, 0, 0 ) )
  171. SendDlgItemMessage( IDC_CHECK_EDIT, BM_CLICK, 0, 0 );
  172. }
  173. }
  174. void CSetupFixedVideoDlg::OnCheckEditLine()
  175. {
  176. // get enable flag
  177. BOOL bEditLine = SendDlgItemMessage( IDC_CHECK_EDIT_LINE, BM_GETCHECK, 0, 0 );
  178. // uncheck another edit mode
  179. SendDlgItemMessage( IDC_CHECK_EDIT_POINT, BM_SETCHECK, 0, 0 );
  180. // set editor mode
  181. m_LocatorWnd.SetEditMode( bEditLine, RGB(0xFF,0xFF,0), CLocatorWnd::EDIT_MODE_LINE );
  182. // enable clear button
  183. ::EnableWindow( GetDlgItem( IDC_BUTTON_CLEAR ), bEditLine );
  184. }
  185. void CSetupFixedVideoDlg::OnCheckEditPoint()
  186. {
  187. // get enable flag
  188. BOOL bEditPoint = SendDlgItemMessage( IDC_CHECK_EDIT_POINT, BM_GETCHECK, 0, 0 );
  189. // uncheck another edit mode
  190. SendDlgItemMessage( IDC_CHECK_EDIT_LINE, BM_SETCHECK, 0, 0 );
  191. // set editor mode
  192. m_LocatorWnd.SetEditMode( bEditPoint, RGB(0xFF,0xFF,0), CLocatorWnd::EDIT_MODE_POINT );
  193. // enable clear button
  194. ::EnableWindow( GetDlgItem( IDC_BUTTON_CLEAR ), bEditPoint );
  195. }