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.

111 lines
3.0 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: BoardReceiverDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of BoardReceiverDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // BoardReceiverDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "BoardReceiver.h"
  18. #include "BoardReceiverDlg.h"
  19. #include "Winspool.h"
  20. /*
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. */
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CBoardReceiverDlg dialog
  29. CBoardReceiverDlg::CBoardReceiverDlg(CWnd* pParent /*=NULL*/)
  30. : CDialog(CBoardReceiverDlg::IDD, pParent)
  31. {
  32. //{{AFX_DATA_INIT(CBoardReceiverDlg)
  33. m_RadioMaster = 0;
  34. //}}AFX_DATA_INIT
  35. }
  36. void CBoardReceiverDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CBoardReceiverDlg)
  40. DDX_Control(pDX, IDC_BUTTON_TARGET_FILE, m_ButtonTargetFile);
  41. DDX_Control(pDX, IDC_COMBO_PORT, m_ComboPort);
  42. DDX_Control(pDX, IDC_EDIT_TARGET_FILE, m_EditTargetFile);
  43. DDX_Radio(pDX, IDC_RADIO_MASTER, m_RadioMaster);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CBoardReceiverDlg, CDialog)
  47. //{{AFX_MSG_MAP(CBoardReceiverDlg)
  48. ON_BN_CLICKED(IDC_BUTTON_TARGET_FILE, OnButtonTargetFile)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CBoardReceiverDlg message handlers
  53. BOOL CBoardReceiverDlg::OnInitDialog()
  54. {
  55. CDialog::OnInitDialog();
  56. DWORD cbNeeded = 0;
  57. DWORD cReturned = 0;
  58. ::EnumPorts( NULL, 2, NULL, 0, &cbNeeded, &cReturned );
  59. PORT_INFO_2 *pPorts = (PORT_INFO_2*) malloc( cbNeeded );
  60. ::EnumPorts( NULL, 2, (PBYTE)pPorts, cbNeeded, &cbNeeded, &cReturned );
  61. for( DWORD i = 0; i < cReturned; i++ )
  62. if( !( pPorts[i].fPortType & ( PORT_TYPE_REDIRECTED | PORT_TYPE_NET_ATTACHED ) ) )
  63. m_ComboPort.AddString( pPorts[i].pPortName );
  64. free( pPorts );
  65. m_ComboPort.SetCurSel( 0 );
  66. SYSTEMTIME st;
  67. GetLocalTime( &st );
  68. TCHAR pFileName[MAX_PATH];
  69. _sntprintf( pFileName, MAX_PATH, "%04d_%02d_%02d_%02d_%02d_%02d.raw", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond );
  70. m_EditTargetFile.SetWindowText( pFileName );
  71. return TRUE;
  72. }
  73. void CBoardReceiverDlg::OnOK()
  74. {
  75. m_EditTargetFile.GetWindowText( m_strFileName );
  76. m_ComboPort.GetWindowText( m_strPort );
  77. CDialog::OnOK();
  78. }
  79. void CBoardReceiverDlg::OnButtonTargetFile()
  80. {
  81. CString defFile;
  82. m_EditTargetFile.GetWindowText( defFile );
  83. char szFilter[] = "BoardReceiver files (*.raw)|*.raw|All Files (*.*)|*.*||";
  84. CFileDialog fd( FALSE, "*.raw", defFile, OFN_HIDEREADONLY, szFilter, this );
  85. if( fd.DoModal() == IDOK )
  86. {
  87. m_EditTargetFile.SetWindowText( fd.GetPathName() );
  88. }
  89. }