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.

120 lines
3.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: BoardReceiverVariableList.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of BoardReceiverVariableList.cpp
  13. //----------------------------------------------------------------------------
  14. // BoardReceiverVariableList.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "BoardReceiver.h"
  18. #include "BoardReceiverVariableList.h"
  19. /*
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. */
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CBoardReceiverVariableList
  28. IMPLEMENT_DYNCREATE(CBoardReceiverVariableList, CListView)
  29. CBoardReceiverVariableList::CBoardReceiverVariableList()
  30. {
  31. }
  32. CBoardReceiverVariableList::~CBoardReceiverVariableList()
  33. {
  34. }
  35. BEGIN_MESSAGE_MAP(CBoardReceiverVariableList, CListView)
  36. //{{AFX_MSG_MAP(CBoardReceiverVariableList)
  37. ON_WM_SIZE()
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CBoardReceiverVariableList drawing
  42. void CBoardReceiverVariableList::OnDraw(CDC* pDC)
  43. {
  44. CDocument* pDoc = GetDocument();
  45. // TODO: add draw code here
  46. }
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CBoardReceiverVariableList diagnostics
  49. #ifdef _DEBUG
  50. void CBoardReceiverVariableList::AssertValid() const
  51. {
  52. CListView::AssertValid();
  53. }
  54. void CBoardReceiverVariableList::Dump(CDumpContext& dc) const
  55. {
  56. CListView::Dump(dc);
  57. }
  58. #endif //_DEBUG
  59. void CBoardReceiverVariableList::OnInitialUpdate()
  60. {
  61. CListView::OnInitialUpdate();
  62. // set REPORT style
  63. LONG lStyle = ::GetWindowLong( GetListCtrl().GetSafeHwnd(), GWL_STYLE );
  64. ::SetWindowLong( GetListCtrl().GetSafeHwnd(), GWL_STYLE, lStyle | LVS_REPORT );
  65. CRect rect;
  66. GetClientRect( &rect );
  67. GetListCtrl().InsertColumn( 0, "Variable", LVCFMT_CENTER, 100, 0 );
  68. GetListCtrl().InsertColumn( 1, "Value", LVCFMT_CENTER, 100, 1 );
  69. GetListCtrl().SetExtendedStyle( LVS_EX_FULLROWSELECT );
  70. GetListCtrl().SetTextBkColor( RGB( 0xDF,0xDF,0xDF ) );
  71. OnSize( 0, rect.Width(), rect.Height() );
  72. }
  73. void CBoardReceiverVariableList::OnSize(UINT nType, int cx, int cy)
  74. {
  75. CListView::OnSize(nType, cx, cy);
  76. int nWidth = cx * 2 / 3;
  77. LVCOLUMN column;
  78. column.mask = LVCF_WIDTH;
  79. GetListCtrl().GetColumn( 0, &column );
  80. column.cx = cx - nWidth;
  81. GetListCtrl().SetColumn( 0, &column );
  82. column.cx = nWidth;
  83. GetListCtrl().SetColumn( 1, &column );
  84. }
  85. BOOL CBoardReceiverVariableList::SetVariable(LPCTSTR pName, LPCTSTR pValue)
  86. {
  87. for( INT i = 0; i < GetListCtrl().GetItemCount(); i++ )
  88. {
  89. CString strName = GetListCtrl().GetItemText( i, 0 );
  90. if( strName == pName )
  91. return GetListCtrl().SetItemText( i, 1, pValue );
  92. }
  93. INT nItem = GetListCtrl().InsertItem( GetListCtrl().GetItemCount(), pName );
  94. GetListCtrl().SetItemText( nItem, 1, pValue );
  95. return TRUE;
  96. }