// SelWaterTankDlg.cpp : implementation file // #include "stdafx.h" #include "SelWaterTankDlg.h" #include "TGAs.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSelWaterTankDlg dialog CSelWaterTankDlg::CSelWaterTankDlg(CWnd* pParent /*=NULL*/) : CDialog(CSelWaterTankDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSelWaterTankDlg) m_iShape = 1; m_dV = 0.0; //}}AFX_DATA_INIT } void CSelWaterTankDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSelWaterTankDlg) DDX_Control(pDX, IDC_LIST_DATA, m_listCtrl); DDX_Radio(pDX, IDC_RADIO_SHAPE1, m_iShape); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSelWaterTankDlg, CDialog) //{{AFX_MSG_MAP(CSelWaterTankDlg) ON_BN_CLICKED(IDC_RADIO_SHAPE1, OnRadioShape1) ON_BN_CLICKED(IDC_RADIO_SHAPE2, OnRadioShape2) ON_NOTIFY(NM_DBLCLK, IDC_LIST_DATA, OnDblclkListData) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSelWaterTankDlg message handlers BOOL CSelWaterTankDlg::OnInitDialog() { CDialog::OnInitDialog(); m_listCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); ResetList(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSelWaterTankDlg::OnRadioShape1() { ResetList(); } void CSelWaterTankDlg::OnRadioShape2() { ResetList(); } void CSelWaterTankDlg::ResetList() { UpdateData(); int nColumnCount = m_listCtrl.GetHeaderCtrl()->GetItemCount(); for(int i=0;iMoveFirst();!pTable->IsEOF();pTable->MoveNext()) { GET_FIELD(pTable, _T("V"), strV); GET_FIELD(pTable, _T("L"), strL); GET_FIELD(pTable, _T("B"), strB); GET_FIELD(pTable, _T("H"), strH); GET_FIELD(pTable, _T("Weight"), strW); GET_FIELD(pTable, _T("Name"), strName); GET_FIELD(pTable, _T("Page"), strPage); if (m_dV > _tstof(strV)) { continue; } m_listCtrl.InsertItem ( nRow, strV, 0 ); m_listCtrl.SetItemText ( nRow, 1, strL); m_listCtrl.SetItemText ( nRow, 2, strB); m_listCtrl.SetItemText ( nRow, 3, strH); m_listCtrl.SetItemText ( nRow, 4, strW); m_listCtrl.SetItemText ( nRow, 5, strName); m_listCtrl.SetItemText ( nRow, 6, strPage); nRow++; } } } void CSelWaterTankDlg::OnOK() { UpdateData(TRUE); POSITION pos = m_listCtrl.GetFirstSelectedItemPosition(); if(!pos) return; int nItem = m_listCtrl.GetNextSelectedItem(pos); m_csCubage = m_listCtrl.GetItemText(nItem, 0); if(m_iShape == 0){ m_iRadius = _ttoi(m_listCtrl.GetItemText(nItem, 1)); m_iHeight = _ttoi(m_listCtrl.GetItemText(nItem, 2)); } else{ m_iLength = _ttoi(m_listCtrl.GetItemText(nItem, 1)); m_iWidth = _ttoi(m_listCtrl.GetItemText(nItem, 2)); m_iHeight = _ttoi(m_listCtrl.GetItemText(nItem, 3)); } CDialog::OnOK(); } void CSelWaterTankDlg::OnDblclkListData(NMHDR* pNMHDR, LRESULT* pResult) { *pResult = 0; OnOK(); }