CTSTR XElement::GetString(CTSTR lpName, TSTR def) const { assert(lpName); XDataItem *item = GetDataItem(lpName); if(item) return item->strData; return def; }
float XElement::GetFloat(CTSTR lpName, float def) const { assert(lpName); XDataItem *item = GetDataItem(lpName); if(item) return (float)tstof(item->strData); return def; }
void XElement::SetFloat(CTSTR lpName, float number) { assert(lpName); String floatStr = FloatString(number); XDataItem *item = GetDataItem(lpName); if(item) { item->strData = floatStr; return; } SubItems << new XDataItem(lpName, floatStr); }
void XElement::SetInt(CTSTR lpName, int number) { assert(lpName); String intStr = IntString(number); XDataItem *item = GetDataItem(lpName); if(item) { item->strData = intStr; return; } SubItems << new XDataItem(lpName, intStr); }
void XElement::SetString(CTSTR lpName, CTSTR lpString) { assert(lpName); if(!lpString) lpString = TEXT(""); XDataItem *item = GetDataItem(lpName); if(item) { item->strData = lpString; return; } SubItems << new XDataItem(lpName, lpString); }
void XElement::SetHex(CTSTR lpName, DWORD hex) { assert(lpName); String hexStr; hexStr << TEXT("0x") << IntString(hex, 16); XDataItem *item = GetDataItem(lpName); if(item) { item->strData = hexStr; return; } SubItems << new XDataItem(lpName, hexStr); }
void CCMSDCommandCellView::FillRow(int nNewItem, MTConnectDataModel::iterator it ) { // Row i m_wndListCtrl.SetItemText( nNewItem, 0, "0"); m_wndListCtrl.SetItemFormat(nNewItem,0, ITEM_FORMAT_ADDBOX,ITEM_IMAGE_ADDBOX ); m_wndListCtrl.SetItemCheck(nNewItem, 0, 1 ); // m_wndListCtrl.SetItemFormat( nNewItem, DEVICECOL, ITEM_FORMAT_COMBO,ITEM_FLAGS_RIGHT| ITEM_FLAGS_NONE, (CListArray<CString> &) allDevicesComboList); m_wndListCtrl.SetItemFormat( nNewItem, TAGCOL, ITEM_FORMAT_NONE, ITEM_FLAGS_LEFT ); m_wndListCtrl.SetItemText( nNewItem, TAGCOL,(*it).first.c_str()); CDataItem d; m_wndListCtrl.SetItemFormat( nNewItem, VALUECOL, ITEM_FORMAT_EDIT, ITEM_FLAGS_RIGHT ); if(GetDataItem( (*it).first, d) && d.type == "ASSET_CHANGED") { m_wndListCtrl.SetItemFormat( nNewItem, VALUECOL, ITEM_FORMAT_NONE, ITEM_FLAGS_RIGHT ); m_wndListCtrl.SetItemText( nNewItem, VALUECOL,"..."); } }
int XElement::GetInt(CTSTR lpName, int def) const { assert(lpName); XDataItem *item = GetDataItem(lpName); if(item) { CTSTR lpValue = item->strData; if( (*LPWORD(lpValue) == 'x0') || (*LPWORD(lpValue) == 'X0') ) { return tstring_base_to_uint(lpValue+2, NULL, 16); } else if(scmpi(lpValue, TEXT("true")) == 0) return 1; else if(scmpi(lpValue, TEXT("false")) == 0) return 0; else return tstring_base_to_uint(lpValue, NULL, 0); } return def; }
LRESULT CCMSDCommandCellView::OnDoubleClicked( LPNMHDR lpNMHDR ) { CListNotify *pListNotify = reinterpret_cast<CListNotify *>( lpNMHDR ); // + Add image // - remove image if(pListNotify->m_nItem>= 0 && pListNotify->m_nItem < Tablesize() && pListNotify->m_nSubItem == VALUECOL) { CString tag =m_wndListCtrl.GetItemText(pListNotify->m_nItem,TAGCOL); CDataItem d; if(GetDataItem((LPCSTR) tag, d) && d.type == "ASSET_CHANGED") { static TCHAR strFilter[] = _T("All Files (*.*)\0*.*\0"); CFileDialog fileDlg(TRUE, _T("*"), NULL, OFN_HIDEREADONLY, strFilter); if( fileDlg.DoModal ()!=IDOK ) return 0; m_wndListCtrl.SetItemText( pListNotify->m_nItem, VALUECOL,fileDlg.m_szFileName); } } return 0; }