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.

125 lines
2.9 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: PropRabbitDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PropRabbitDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // PropRabbitDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "setuplgs.h"
  18. #include "PropRabbitDlg.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CPropRabbitDlg dialog
  26. CPropRabbitDlg::CPropRabbitDlg(CWnd* pParent /*=NULL*/)
  27. : CDialog(CPropRabbitDlg::IDD, pParent)
  28. {
  29. //{{AFX_DATA_INIT(CPropRabbitDlg)
  30. m_nAddress = 0;
  31. m_Name = _T("");
  32. //}}AFX_DATA_INIT
  33. }
  34. void CPropRabbitDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CPropRabbitDlg)
  38. DDX_Text(pDX, IDC_EDIT_RABBIT_ADDRESS, m_nAddress);
  39. DDV_MinMaxInt(pDX, m_nAddress, 0, 127);
  40. DDX_Text(pDX, IDC_EDIT_RABBIT_NAME, m_Name);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CPropRabbitDlg, CDialog)
  44. //{{AFX_MSG_MAP(CPropRabbitDlg)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CPropRabbitDlg message handlers
  49. BOOL CPropRabbitDlg::OnInitDialog()
  50. {
  51. CDialog::OnInitDialog();
  52. m_nAddress = m_pDevice->m_nAddress;
  53. m_Name = m_pDevice->m_Name;
  54. SetWindowText( m_pDevice->m_DeviceName );
  55. UINT i = IDC_CHECK_DC_01;
  56. for( int k = 0; k < m_pDevice->GetPinCount(); k++ )
  57. {
  58. COFPin *pPin = m_pDevice->GetPin(k);
  59. if( pPin->GetType() == PT_SENSOR_INPUT )
  60. {
  61. GetDlgItem(i)->EnableWindow( TRUE );
  62. SendDlgItemMessage( i, BM_SETCHECK, pPin->GetParam(), 0 );
  63. i++;
  64. }
  65. }
  66. UpdateData( FALSE );
  67. return TRUE; // return TRUE unless you set the focus to a control
  68. // EXCEPTION: OCX Property Pages should return FALSE
  69. }
  70. int CPropRabbitDlg::DoModal(COFDevice *pDevice)
  71. {
  72. m_pDevice = (COFDeviceRabbit*)pDevice;
  73. return CDialog::DoModal();
  74. }
  75. void CPropRabbitDlg::OnOK()
  76. {
  77. UpdateData( TRUE );
  78. BOOL bChanged = FALSE;
  79. UINT i = IDC_CHECK_DC_01;
  80. for( int k = 0; k < m_pDevice->GetPinCount(); k++ )
  81. {
  82. COFPin *pPin = m_pDevice->GetPin(k);
  83. if( pPin->GetType() == PT_SENSOR_INPUT )
  84. {
  85. BOOL bCheck = SendDlgItemMessage( i, BM_GETCHECK, 0, 0 );
  86. if( bCheck != pPin->GetParam() )
  87. {
  88. pPin->SetParam( bCheck );
  89. bChanged= TRUE;
  90. }
  91. i++;
  92. }
  93. }
  94. if( m_pDevice->m_nAddress != m_nAddress ||
  95. m_pDevice->m_Name != m_Name ||
  96. bChanged )
  97. {
  98. m_pDevice->m_nAddress = m_nAddress;
  99. m_pDevice->m_Name = m_Name;
  100. CDialog::OnOK();
  101. }
  102. else
  103. CDialog::OnCancel();
  104. }