SelectVariantDlg.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // SelectVariantDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "icredit.h"
  5. #include "SelectVariantDlg.h"
  6. #include "kernel.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSelectVariantDlg dialog
  14. CSelectVariantDlg::CSelectVariantDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CSelectVariantDlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CSelectVariantDlg)
  18. // NOTE: the ClassWizard will add member initialization here
  19. m_nType = 0;
  20. //}}AFX_DATA_INIT
  21. }
  22. void CSelectVariantDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CSelectVariantDlg)
  26. DDX_Control(pDX, IDC_VARLIST, m_ctrlVariant);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CSelectVariantDlg, CDialog)
  30. //{{AFX_MSG_MAP(CSelectVariantDlg)
  31. ON_NOTIFY(NM_CLICK, IDC_VARLIST, OnClickVarlist)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CSelectVariantDlg message handlers
  36. BOOL CSelectVariantDlg::OnInitDialog()
  37. {
  38. CDialog::OnInitDialog();
  39. CString strVar=_T("±äÁ¿");
  40. CString strDes=_T("ÃèÊö");
  41. m_ctrlVariant.InsertColumn(0, strVar, LVCFMT_LEFT,
  42. 95 ,0);
  43. m_ctrlVariant.InsertColumn(1, strDes, LVCFMT_LEFT,
  44. 190 ,1);
  45. if ( m_nType == 1 ) // di
  46. {
  47. }
  48. else if ( m_nType == 0 ) // ai
  49. {
  50. int size = pVariantsManager->m_analog.GetSize();
  51. for ( int i =0; i<size; i++)
  52. {
  53. CAnalog* pAnalog = pVariantsManager->m_analog.GetAt(i);
  54. strVar = pAnalog->m_strName;
  55. strDes = pAnalog->m_strDesc;
  56. TCHAR buf[200];
  57. LV_ITEM lvitem;
  58. int iActualItem;
  59. lvitem.mask = LVIF_TEXT;
  60. lvitem.iItem = i ;
  61. lvitem.iSubItem = 0;
  62. strncpy (buf, strVar, 100);
  63. lvitem.pszText = buf;
  64. iActualItem = m_ctrlVariant.InsertItem(&lvitem); // insert new item
  65. //________________________________________________________________________________________________
  66. lvitem.mask = LVIF_TEXT;
  67. lvitem.iItem = iActualItem;
  68. lvitem.iSubItem = 1;
  69. strncpy (buf, strDes, 100);
  70. lvitem.pszText = buf;
  71. m_ctrlVariant.SetItem(&lvitem);
  72. }
  73. }
  74. return TRUE;
  75. }
  76. void CSelectVariantDlg::OnOK()
  77. {
  78. CDialog::OnOK();
  79. }
  80. void CSelectVariantDlg::OnClickVarlist(NMHDR* pNMHDR, LRESULT* pResult)
  81. {
  82. CPoint point;
  83. GetCursorPos(&point);
  84. m_ctrlVariant.ScreenToClient(&point);
  85. LVHITTESTINFO lvHTI;
  86. lvHTI.pt.x = point.x;
  87. lvHTI.pt.y = point.y;
  88. m_ctrlVariant.SubItemHitTest(&lvHTI);
  89. int m_nItem = lvHTI.iItem; //ÐкÅ
  90. char var[100];
  91. m_ctrlVariant.GetItemText(m_nItem, 0, var, 100);
  92. m_strVar = var;
  93. *pResult = 0;
  94. }