// DialListMeasuData.cpp : implementation file // #include "stdafx.h" #include "GeoMative.h" #include "DialListMeasuData.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDialListMeasuData dialog extern int g_UIOffset; extern int g_iUILanguage; CDialListMeasuData::CDialListMeasuData(CWnd* pParent /*=NULL*/) : CDialog(CDialListMeasuData::IDD, pParent) { //{{AFX_DATA_INIT(CDialListMeasuData) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // m_iMeasuType = 0; m_iSptType = -1; m_strMeasuStatus = _T(""); m_pMeasuStatus = NULL; } void CDialListMeasuData::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDialListMeasuData) DDX_Control(pDX, IDC_LIST_MEASURE, m_listData); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDialListMeasuData, CDialog) //{{AFX_MSG_MAP(CDialListMeasuData) ON_WM_SHOWWINDOW() ON_BN_CLICKED(IDC_BTN_LIST_PRE, OnBtnListPre) ON_BN_CLICKED(IDC_BTN_LIST_NEXT, OnBtnListNext) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDialListMeasuData message handlers BOOL CDialListMeasuData::OnInitDialog() { CDialog::OnInitDialog(); if (LANG_ZHCN == g_iUILanguage) { GetDlgItem(IDC_BTN_LIST_PRE)->SetWindowText(_T("上一页")); GetDlgItem(IDC_BTN_LIST_NEXT)->SetWindowText(_T("下一页")); } // TODO: Add extra initialization here CString strColTitle; int iColIndex = 0; m_listData.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES); m_listData.InsertColumn(iColIndex++, _T("ID"),LVCFMT_LEFT,60); // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_SCRIPT_C1); m_listData.InsertColumn(iColIndex++, _T("A"), LVCFMT_CENTER, 60); // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_SCRIPT_C2); m_listData.InsertColumn(iColIndex++, _T("B"), LVCFMT_CENTER, 60); // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_SCRIPT_P1); m_listData.InsertColumn(iColIndex++, _T("M"), LVCFMT_CENTER, 60); // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_SCRIPT_P2); m_listData.InsertColumn(iColIndex++, _T("N"), LVCFMT_CENTER, 60); // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_SCRIPT_N); m_listData.InsertColumn(iColIndex++, _T("Stack"), LVCFMT_CENTER, 80); // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_SCRIPT_K); m_listData.InsertColumn(iColIndex++, _T("K"), LVCFMT_CENTER, 120); // strColTitle.Empty(); // strColTitle.LoadString(IDS_MEASU_TD_V); m_listData.InsertColumn(iColIndex++, _T("V(mV)"), LVCFMT_CENTER, 120); // strColTitle.Empty(); // strColTitle.LoadString(IDS_MEASU_TD_I); m_listData.InsertColumn(iColIndex++, _T("I(mA)"), LVCFMT_CENTER, 120); // strColTitle.Empty(); // strColTitle.LoadString(IDS_MEASU_TD_R0); m_listData.InsertColumn(iColIndex++, _T("R0(Ohm*m)"), LVCFMT_CENTER, 120); // strColTitle.Empty(); // strColTitle.LoadString(IDS_MEASU_TD_SP); //m_listData.InsertColumn(iColIndex++, _T("SP(mV)"), LVCFMT_CENTER, 110); std::vector vtData; if (m_taskOper.QueryTdDataFromTsn(m_iTaskID, m_iSptType, 1, MAX_LIST_SHOW_NUM, vtData)) { if (!vtData.empty()) OnShowTdData(vtData); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDialListMeasuData::ShowMeasuStatus(CString strStatus) { m_strMeasuStatus = strStatus; GetDlgItem(IDC_STATIC_MEASU_SHOW_STATUS)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_MEASU_SHOW_STATUS)->SetWindowText(m_strMeasuStatus); } void CDialListMeasuData::EnablePreviewBtn(bool bIsEnable) { GetDlgItem(IDC_BTN_LIST_PRE)->EnableWindow(bIsEnable); GetDlgItem(IDC_BTN_LIST_NEXT)->EnableWindow(bIsEnable); } void CDialListMeasuData::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); if (TRUE == bShow) { CRect rect,orgrect; GetClientRect(&rect); orgrect = rect; rect.left += 5; rect.top += 5; rect.right -= 5; rect.bottom -= 27; m_listData.MoveWindow(&rect); GetDlgItem(IDC_STATIC_MEASU_SHOW_STATUS)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_MEASU_SHOW_STATUS)->SetWindowText(m_strMeasuStatus); CRect ctrRect; GetDlgItem(IDC_BTN_LIST_PRE)->GetClientRect(&ctrRect); GetDlgItem(IDC_BTN_LIST_PRE)->MoveWindow(orgrect.Width()/2-2-ctrRect.Width(), orgrect.bottom-ctrRect.Height(), ctrRect.Width(),ctrRect.Height()); GetDlgItem(IDC_BTN_LIST_NEXT)->MoveWindow(orgrect.Width()/2+2, orgrect.bottom-ctrRect.Height(), ctrRect.Width(),ctrRect.Height()); CRect rectStatus; rectStatus.left = rect.left; rectStatus.top = orgrect.bottom-ctrRect.Height()+7; rectStatus.right = orgrect.Width()/2-2-ctrRect.Width()-5; rectStatus.bottom = orgrect.bottom; GetDlgItem(IDC_STATIC_MEASU_SHOW_STATUS)->MoveWindow(&rectStatus); } // TODO: Add your message handler code here } void CDialListMeasuData::OnBtnListPre() { // TODO: Add your control notification handler code here if (*m_pMeasuStatus == true) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("正在测试中,不能操作")); else MessageBoxEx(NULL, _T("Can not operator when data is being measured."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } if (m_listData.GetItemCount() < 1) { return; } int iID = atoi(m_listData.GetItemText(0,0)); if (1 == iID) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("已经是首页了")); else MessageBoxEx(NULL, _T("It's already been the first page."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } std::vector vtData; if (m_taskOper.QueryTdDataFromTsn(m_iTaskID, m_iSptType, iID, -1*MAX_LIST_SHOW_NUM, vtData)) { if (vtData.empty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("已经是首页了")); else MessageBoxEx(NULL, _T("It's already been the first page."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } OnShowTdData(vtData); } } void CDialListMeasuData::OnBtnListNext() { // TODO: Add your control notification handler code here if (*m_pMeasuStatus == true) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("正在测试中,不能操作")); else MessageBoxEx(NULL, _T("Can not operator when data is being measured."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } if (m_listData.GetItemCount() < 1) { return; } if (m_listData.GetItemCount() < MAX_LIST_SHOW_NUM) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("已经是最后一页了")); else MessageBoxEx(NULL, _T("It's already been the last page."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } int iID = atoi(m_listData.GetItemText(m_listData.GetItemCount()-1,0)); std::vector vtData; vtData.clear(); if (m_taskOper.QueryTdDataFromTsn(m_iTaskID, m_iSptType, iID+1, MAX_LIST_SHOW_NUM, vtData)) { if (vtData.empty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("已经是最后一页了")); else MessageBoxEx(NULL, _T("It's already been the last page."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } OnShowTdData(vtData); } } void CDialListMeasuData::OnShowTdData(const std::vector& vtTdData) { if (vtTdData.empty()) { return; } m_listData.DeleteAllItems(); CString strTxt; for (int i = 0; i < vtTdData.size(); i++) { strTxt.Empty(); strTxt.Format(_T("%d"),vtTdData[i].iID); m_listData.InsertItem(i, strTxt); int iColIndex = 1; if (0 == m_iSptType) { strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fA); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fB); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fX); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fY); m_listData.SetItemText(i, iColIndex++, strTxt); } else { strTxt.Empty(); strTxt.Format(_T("%d"),vtTdData[i].iA); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%d"),vtTdData[i].iB); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%d"),vtTdData[i].iM); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%d"),vtTdData[i].iN); m_listData.SetItemText(i, iColIndex++, strTxt); } strTxt.Empty(); strTxt.Format(_T("%d"),vtTdData[i].ucStack); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fK); m_listData.SetItemText(i, iColIndex++, strTxt); if (vtTdData[i].ucIsUse != 0) { strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fV); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fI); m_listData.SetItemText(i, iColIndex++, strTxt); strTxt.Empty(); strTxt.Format(_T("%.2f"),vtTdData[i].fR0); m_listData.SetItemText(i, iColIndex++, strTxt); // strTxt.Empty(); // strTxt.Format(_T("%.2f"),vtTdData[i].fSP); // m_listData.SetItemText(i, iColIndex++, strTxt); } m_listData.SetItemData(i,vtTdData[i].iID); } }