void CCaseTree::FillParamItem(HTREEITEM pParent, ParamItem* pParamItem[], int nCount, int& i, ParamItem* pParentParamItem) { HTREEITEM node = NULL; for(i = i; i < nCount; i++) { if(pParent) { //ParamItem_Dump(pParamItem[i]); ASSERT(pParent && pParentParamItem); if(pParamItem[i]->m_Level == pParentParamItem->m_Level + 1) { node = InsertItem(pParamItem[i]->m_pName, 0, 0, pParent); SetItemData(node, (DWORD_PTR)pParamItem[i]); SetCheck(node, pParamItem[i]->m_isChecked); i++; FillParamItem(node, pParamItem, nCount, i, pParamItem[i-1]); } else { i--; return ; } } else if(pParamItem[i]->m_Level == 0) { //ParamItem_Dump(pParamItem[i]); node = InsertItem(pParamItem[i]->m_pName, 0, 0); SetItemData(node, (DWORD_PTR)pParamItem[i]); SetCheck(node, pParamItem[i]->m_isChecked); i++; FillParamItem(node, pParamItem, nCount, i, pParamItem[i-1]); } } }
void CTDLFindTaskAttributeComboBox::BuildCombo() { ResetContent(); CLocalizer::EnableTranslation(*this, FALSE); int nAttrib; for (nAttrib = 0; nAttrib < ATTRIB_COUNT; nAttrib++) { const TDCATTRIBUTE& ap = ATTRIBUTES[nAttrib]; if (ap.nAttribResID) { CEnString sAttrib(ap.nAttribResID); DWORD dwItemData = EncodeItemData(ap.attrib, FALSE); int nItem = AddString(sAttrib); SetItemData(nItem, dwItemData); // is it a date // then add relative version too if (AttributeIsDate(ap.attrib)) { dwItemData = EncodeItemData(ap.attrib, TRUE); sAttrib += ' '; sAttrib += CEnString(IDS_TDLBC_RELATIVEDATESUFFIX); nItem = AddString(sAttrib); SetItemData(nItem, dwItemData); } } } // custom attributes for (nAttrib = 0; nAttrib < m_aAttribDefs.GetSize(); nAttrib++) { const TDCCUSTOMATTRIBUTEDEFINITION& attribDef = m_aAttribDefs[nAttrib]; CEnString sAttrib(IDS_CUSTOMCOLUMN, attribDef.sLabel); TDC_ATTRIBUTE attrib = attribDef.GetAttributeID(); int nItem = AddString(sAttrib); DWORD dwItemData = EncodeItemData(attrib, FALSE); SetItemData(nItem, dwItemData); // is it a date if (AttributeIsDate(attrib)) { dwItemData = EncodeItemData(attrib, TRUE); sAttrib.Format(IDS_CUSTOMRELDATECOLUMN, attribDef.sLabel); nItem = AddString(sAttrib); SetItemData(nItem, dwItemData); } } // recalc combo drop width CDialogHelper::RefreshMaxDropWidth(*this); }
void CCaseTreeCtrl::FillTreeNodeData(HTREEITEM pParent, TreeNodeData* pTreeNodeData[], int nCount, int& i, TreeNodeData* pParentTreeNodeData) { HTREEITEM node = NULL; for(i = i; i < nCount; i++) { if(pParent) { //TreeNodeData_Dump(pTreeNodeData[i]); ASSERT(pParent && pParentTreeNodeData); if(pTreeNodeData[i]->m_Level == pParentTreeNodeData->m_Level + 1) { node = InsertItem(pTreeNodeData[i]->m_pName, 0, 0, pParent); SetItemData(node, (DWORD_PTR)pTreeNodeData[i]); i++; FillTreeNodeData(node, pTreeNodeData, nCount, i, pTreeNodeData[i-1]); } else { i--; return ; } } else if(pTreeNodeData[i]->m_Level == 0) { //TreeNodeData_Dump(pTreeNodeData[i]); node = InsertItem(pTreeNodeData[i]->m_pName, 0, 0); SetItemData(node, (DWORD_PTR)pTreeNodeData[i]); i++; FillTreeNodeData(node, pTreeNodeData, nCount, i, pTreeNodeData[i-1]); } } }
BOOL CSearchBox::InitStocks( BOOL bHasSTTTech, BOOL bShowOnSel, BOOL bDuplicate ) { ResetContent( ); m_bShowOnSel = bShowOnSel; CStockContainer & container = AfxGetStockContainer(); InitStorage( bDuplicate ? container.GetSize()*2 : container.GetSize(), 32 ); for( int i=0; i<container.GetSize(); i++ ) { CStockInfo & info = container.ElementAt(i); if( !info.IsValidStock() ) continue; CString strTemp = info.GetStockCode(); while( strTemp.GetLength() < 8 ) strTemp += ' '; strTemp += info.GetStockName(); int nItem = AddString( strTemp ); SetItemData( nItem, i ); if( bDuplicate ) { strTemp = info.GetStockShortName(); while( strTemp.GetLength() < 8 ) strTemp += ' '; strTemp += info.GetStockName(); if( CB_ERR == SelectString( 0, strTemp ) ) { nItem = AddString( strTemp ); SetItemData( nItem, i ); } } } if( bHasSTTTech ) { // 技术指标项 UINT nTechUserCount = CTechUser::GetTechUserCount(); for( UINT i=STT_MIN; i <= STT_MAX+nTechUserCount; i ++ ) { UINT nTech = i; if( nTech > STT_MAX ) nTech = i-STT_MAX-1+STT_USER_MIN; CString strTemp = AfxGetSTTShortName( nTech ); while( strTemp.GetLength() < 8 ) strTemp += ' '; strTemp += AfxGetSTTName( nTech ); int nItem = AddString( strTemp ); SetItemData( nItem, nTech | SEARCHBOX_SIGNBIT_STT ); } // 快捷键项 for( UINT i = ACCE_MIN; i <= ACCE_MAX; i++ ) { CString strTemp = AfxGetAccelerator( i, 8 ); SetItemData( AddString(strTemp), i | SEARCHBOX_SIGNBIT_ACCE ); } } return TRUE; }
int CMapListbox::OnCreate(LPCREATESTRUCT lpCreateStruct) { int nRet = CPaneTreeCtrl::OnCreate(lpCreateStruct); if (nRet < 0) return nRet; m_imageList.Create(ICON_CX,ICON_CY,ILC_MASK|ILC_COLOR32,0,11); SetImageList(&m_imageList,TVSIL_NORMAL); m_imageList.Add(AfxGetApp()->LoadIcon(IDI_HOUSE)); HTREEITEM hRootItem = InsertItem(CTinyString(IDS_BUILDING),0,0); SetItemData(hRootItem,IDC_BTN_BKGNDMAIN); UINT cmds[] = { IDS_WAY,IDS_GREEN,IDS_ELECTRONIC,IDS_WATER,IDS_WARM,IDS_OTHER }; for (int i=1; i<_countof(cmds); ++i) { m_imageList.Add(AfxGetApp()->LoadIcon(cmds[i])); HTREEITEM hTreeItem = InsertItem(CTinyString(cmds[i]),i,i,hRootItem); SetItemData(hTreeItem,cmds[i]); } Expand(hRootItem,TVE_EXPAND); SelectItem(hRootItem); ModifyStyle(0,TVS_FULLROWSELECT); SetItemHeight(80); return nRet; }
HTREEITEM MyGameTreeCtrl::InsertItem( const TREENODE& treeNode ,HTREEITEM hParent,HTREEITEM hAfter) { if( treeNode.bIsLeaf ) { if( treeNode.strImage1 == "") //old item { HTREEITEM hTreeItem = CMyTreeCtrl::InsertItem( treeNode.strText,treeNode.strImage2,hParent,hAfter ); SetItemData( hTreeItem,treeNode.iIndex ); return hTreeItem; } else { HTREEITEM hTreeItem = CMyTreeCtrl::InsertItem( treeNode.strText,treeNode.strImage1,hParent,hAfter ); if( hTreeItem != NULL ) { m_mapNode[hTreeItem] = make_pair( treeNode.strImage1,treeNode.strImage2 ); } SetItemData( hTreeItem,treeNode.iIndex ); return hTreeItem; } } else { HTREEITEM hTreeItem = CMyTreeCtrl::InsertItem( treeNode.strText,treeNode.strImage1,hParent,hAfter ); if( hTreeItem != NULL ) { m_mapNode[hTreeItem] = make_pair( treeNode.strImage1,treeNode.strImage2 ); } return hTreeItem; } }
void CColorCombo::InitDialog(HWND hWndCtrl, bool bDefaultColors, bool bAllowOffOption) { if (!hWndCtrl) return; SubclassWindow(hWndCtrl); AddComboToList(); long lWidth = GetDroppedWidth(); long lRet = SetDroppedWidth(dtoi(2.75 * lWidth)); // Stuff the combobox with colors // Add a place holder for the Custom option (the color picker) int nItem = AddString(""); SetItemData(nItem, CLR_NONE); if (bAllowOffOption) { nItem = AddString(""); SetItemData(nItem, CLR_DEFAULT); } if (bDefaultColors) { for (int i = 0; i < NDEFAULTCOLORS; i++) { nItem = AddString(""); SetItemData(nItem, CColorCombo::m_DefaultColors[i].Color); } } }
BOOL CPropTreeItemCombo::CreateComboBoxBool() { ASSERT(m_pProp!=NULL); if (IsWindow(m_hWnd)) DestroyWindow(); // force as a non-visible child window DWORD dwStyle = WS_CHILD|WS_VSCROLL|CBS_SORT|CBS_DROPDOWNLIST; if (!Create(dwStyle, CRect(0,0,0,0), m_pProp->GetCtrlParent(), GetCtrlID())) { TRACE0("CPropTreeItemCombo::CreateComboBoxBool() - failed to create combo box\n"); return FALSE; } SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject); // file the combo box LONG idx; CString s; s.LoadString(IDS_TRUE); idx = AddString(s); SetItemData(idx, TRUE); s.LoadString(IDS_FALSE); idx = AddString(s); SetItemData(idx, FALSE); return TRUE; }
int CXTPSyntaxEditColorComboBox::SetAutoColor(COLORREF crColor, LPCTSTR lpszAutoText/*=NULL*/) { CString csAuto; if (lpszAutoText == NULL) { XTPResourceManager()->LoadString( &csAuto, XTP_IDS_CLR_AUTOMATIC); int nTipIndex = csAuto.Find(_T('\n'), 0); if (nTipIndex > 0) csAuto.ReleaseBuffer(nTipIndex); } else { csAuto = lpszAutoText; } if (crColor == COLORREF_NULL) { m_crAuto = COLORREF_NULL; int iIndex = FindStringExact(-1, csAuto); if (iIndex != CB_ERR) { return DeleteString(iIndex); } return CB_ERR; } if (m_crAuto == COLORREF_NULL) { int iIndex = InsertString(0, csAuto); if (iIndex != CB_ERR) { m_crAuto = crColor; SetItemData(iIndex, (DWORD)m_crAuto); RedrawWindow(); return iIndex; } } else { int iIndex = FindStringExact(-1, csAuto); if (iIndex != CB_ERR) { m_crAuto = crColor; SetItemData(iIndex, (DWORD)m_crAuto); RedrawWindow(); return iIndex; } } return CB_ERR; }
void CSchemaCombo::Load(LPCTSTR pszSelectURI, int nType, int nAvailability, BOOL bReset) { if ( ( GetStyle() & CBS_OWNERDRAWVARIABLE ) == 0 ) { ModifyStyle( 0, CBS_OWNERDRAWVARIABLE|CBS_HASSTRINGS ); } SetExtendedUI(); m_nType = nType; m_nAvailability = nAvailability; if ( bReset ) ResetContent(); if ( bReset && m_sNoSchemaText.GetLength() ) { SetItemData( AddString( _T(" ") ), 0 ); SetCurSel( 0 ); } for ( POSITION pos = SchemaCache.GetIterator() ; pos ; ) { CSchemaPtr pSchema = SchemaCache.GetNext( pos ); BOOL bSelected = pSchema->CheckURI( pszSelectURI ); if ( ! bReset ) { int nIndex = FindSchema( pSchema ); if ( nIndex >= 0 ) { if ( bSelected ) SetCurSel( nIndex ); continue; } } if ( ( bSelected || pSchema->m_nType == nType || nType == -1 ) && ( bSelected || pSchema->m_nAvailability <= nAvailability ) ) { int nIndex = AddString( pSchema->m_sTitle ); SetItemData( nIndex, (LPARAM)pSchema ); if ( bSelected ) SetCurSel( nIndex ); } } if ( bReset && nAvailability < CSchema::saMax ) { SetItemData( AddString( _T("ZZZ") ), 0 ); } }
int CXTPSyntaxEditColorComboBox::SetUserColor(COLORREF crColor, LPCTSTR lpszUserText/*=NULL*/) { CString csCustom; if (lpszUserText == NULL) { XTPResourceManager()->LoadString( &csCustom, XTP_IDS_EDIT_CUSTOM); } else { csCustom = lpszUserText; } if (crColor == COLORREF_NULL) { m_crUser = COLORREF_NULL; int iIndex = FindStringExact(-1, csCustom); if (iIndex != CB_ERR) { return DeleteString(iIndex); } return CB_ERR; } if (m_crUser == COLORREF_NULL) { int iIndex = AddString(csCustom); if (iIndex != CB_ERR) { m_crUser = crColor; SetItemData(iIndex, (DWORD)m_crUser); RedrawWindow(); return iIndex; } } else { int iIndex = FindStringExact(-1, csCustom); if (iIndex != CB_ERR) { m_crUser = crColor; SetItemData(iIndex, (DWORD)m_crUser); RedrawWindow(); return iIndex; } } return CB_ERR; }
void CTDLFilterDateComboBox::FillCombo() { ASSERT(GetSafeHwnd()); if (GetCount()) return; // already called CLocalizer::EnableTranslation(*this, FALSE); TCHAR nLetter = 'A'; for (int nItem = 0; nItem < NUM_DATEFILTER; nItem++) { CEnString sFilter(DATE_FILTERS[nItem][0]); UINT nFilter = DATE_FILTERS[nItem][1]; CString sText; if (nFilter == FD_ANY || nFilter == FD_NONE) sText = sFilter; else { sText.Format(_T("%c)\t%s"), nLetter, sFilter); nLetter++; } int nIndex = AddString(sText); ASSERT (nIndex != CB_ERR); if (nIndex != CB_ERR) SetItemData(nIndex, nFilter); } CDialogHelper::RefreshMaxDropWidth(*this); }
void wxAdvancedListCtrl::Sort() { SetSortArrow(SortCol, SortOrder); if (SortCol == m_SpecialColumn) { SortItems(wxListCompareFunction, SortOrder); ColourList(); return; } #if 0 // prime 'er up long item = GetNextItem(-1); while(item != -1) { SetItemData(item, item); item = GetNextItem(item); } #endif // sort the list by column Sort(SortCol, SortOrder); }
void SymbolTree::UpdateGuiItem(TagEntry& data, const wxString& key) { if (!m_tree) return; TagNode* node = m_tree->Find(key); if ( node ) { // Update the new data with the gui tree item id data.SetTreeItemId( node->GetData().GetTreeItemId() ); node->SetData(data); // Update Icon if needed int iconIndex = GetItemIconIndex(data.GetKind(), data.GetAccess()); int curIconIndex = -1; wxTreeItemId itemId = node->GetData().GetTreeItemId(); if (itemId.IsOk()) { curIconIndex = GetItemImage(itemId); if (curIconIndex != iconIndex ) { // Need to update the image as well SetItemImage(node->GetData().GetTreeItemId(), iconIndex); SetItemImage(node->GetData().GetTreeItemId(), iconIndex, wxTreeItemIcon_Selected); } // if(curIconIndex != iconIndex ) //update the linenumber and file MyTreeItemData *item_data = new MyTreeItemData(data.GetFile(), data.GetPattern()); wxTreeItemData *old_data = GetItemData(itemId); if (old_data) delete old_data; SetItemData(itemId, item_data); } } }
void CDownloads_Groups::InsertDeleted() { m_hDeleted = InsertItem (TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT, LS (L_DELETED), 6, 6, 0, 0, 0, TVI_ROOT, TVI_LAST); SetItemData (m_hDeleted, NULL); }
/* ================ CPathTreeCtrl::AddPathToTree Adds a new item to the tree. Assumes new paths after the current stack path do not yet exist. ================ */ HTREEITEM CPathTreeCtrl::AddPathToTree( const idStr &pathName, const int id, idPathTreeStack &stack ) { int lastSlash; idStr itemName, tmpPath; HTREEITEM item; lastSlash = pathName.Last( '/' ); while( stack.Num() > 1 ) { if ( pathName.Icmpn( stack.TopName(), stack.TopNameLength() ) == 0 ) { break; } stack.Pop(); } while( lastSlash > stack.TopNameLength() ) { pathName.Mid( stack.TopNameLength(), pathName.Length(), tmpPath ); tmpPath.Left( tmpPath.Find( '/' ), itemName ); item = InsertItem( itemName, stack.TopItem() ); stack.Push( item, itemName ); } pathName.Mid( stack.TopNameLength(), pathName.Length(), itemName ); item = InsertItem( itemName, stack.TopItem() ); SetItemData( item, id ); return item; }
P3DPlantModelTreeCtrl::P3DPlantModelTreeCtrl (wxWindow *parent, P3DPlantModel *PlantModel, P3DBranchPanel *BranchPanel) : wxTreeCtrl(parent,PLANT_TREE_CTRL_ID,wxDefaultPosition, wxDefaultSize,wxTR_HAS_BUTTONS | wxRAISED_BORDER) { this->BranchPanel = BranchPanel; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); P3DBranchModel *PlantBase; PlantBase = PlantModel->GetPlantBase(); wxTreeItemId RootId = AddRoot(MakeTreeItemLabel(PlantBase->GetName(),PlantBase)); SetItemData(RootId,new P3DPlantModelTreeCtrlItemData(PlantBase)); AppendChildrenRecursive(PlantBase,RootId); #if defined(__WXMSW__) { SetItemBold(RootId,true); } #endif }
void WIDGET_HOTKEY_LIST::updateShownItems( const wxString& aFilterStr ) { Freeze(); DeleteAllItems(); HOTKEY_FILTER filter( aFilterStr ); for( auto& section: m_hk_store.GetSections() ) { // Create parent tree item wxTreeListItem parent = AppendItem( GetRootItem(), section.m_name ); for( auto& hotkey: section.m_hotkeys ) { if( filter.FilterMatches( hotkey.GetCurrentValue() ) ) { wxTreeListItem item = AppendItem( parent, wxEmptyString ); SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( hotkey ) ); } } Expand( parent ); } UpdateFromClientData(); Thaw(); }
void ThreadList::updateThreads(const ProcessInfo* processInfo, SymbolInfo *symInfo) { this->selected_threads.clear(); DeleteAllItems(); this->threads.clear(); ok_button->Enable(false); all_button->Enable(false); if(processInfo != NULL) { this->process_handle = processInfo->getProcessHandle(); this->syminfo = symInfo; this->threads = processInfo->threads; int numDisplayedThreads = getNumDisplayedThreads(); for(int i=0; i<numDisplayedThreads; ++i) { long tmp = this->InsertItem(i, "", -1); SetItemData(tmp, i); } all_button->Enable(this->threads.size() != 0); lastTime = wxGetLocalTimeMillis(); updateTimes(); updateSorting(); fillList(); } }
// 添加节点 // hParent [IN] 父节点 // sName [IN] 节点名 // dwData [IN] 节点名 // dwIcon [IN] 节点图标 HTREEITEM CXTTreeCtrl::AddNode(HTREEITEM hParent, CString sName, DWORD dwData, DWORD dwIcon) { HTREEITEM hItem = InsertItem(sName, dwIcon, dwIcon, hParent, TVI_LAST); SetItemData(hItem, dwData); return hItem; }
// wird für jedes zu löschende Item gerufen void CObjectClassStatistics::DeletingItem(HTREEITEM hItem) { CItemCallback *pItemCB = reinterpret_cast<CItemCallback *>(GetItemData(hItem)); DELETE_OBJ(pItemCB); SetItemData(hItem, NULL); }
void CSizeComboBox::InsertSize(int nSize) { ASSERT(nSize > 0); DWORD dwSize = (DWORD)nSize; TCHAR buf[10]; TwipsToPointString(buf, nSize); if (FindStringExact(-1, buf) == CB_ERR) { int nIndex = -1; int nPos = 0; DWORD dw; while ((dw = GetItemData(nPos)) != CB_ERR) { if (dw > dwSize) { nIndex = nPos; break; } nPos++; } nIndex = InsertString(nIndex, buf); ASSERT(nIndex != CB_ERR); if (nIndex != CB_ERR) SetItemData(nIndex, dwSize); } }
/* ================ CPathTreeCtrl::InsertPathIntoTree Inserts a new item going from the root down the tree only creating paths where necessary. This is slow and should only be used to insert single items. ================ */ HTREEITEM CPathTreeCtrl::InsertPathIntoTree( const idStr &pathName, const int id ) { int lastSlash; idStr path, tmpPath, itemName; HTREEITEM item, parentItem; parentItem = NULL; item = GetRootItem(); lastSlash = pathName.Last( '/' ); while( item && lastSlash > path.Length() ) { itemName = GetItemText( item ); tmpPath = path + itemName; if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) { parentItem = item; item = GetChildItem( item ); path = tmpPath + "/"; } else { item = GetNextSiblingItem( item ); } } while( lastSlash > path.Length() ) { pathName.Mid( path.Length(), pathName.Length(), tmpPath ); tmpPath.Left( tmpPath.Find( '/' ), itemName ); parentItem = InsertItem( itemName, parentItem ); path += itemName + "/"; } pathName.Mid( path.Length(), pathName.Length(), itemName ); item = InsertItem( itemName, parentItem, TVI_SORT ); SetItemData( item, id ); return item; }
int CFontComboBox::AddFont(LOGFONT *pLF, DWORD FontType) { int nEntry; FONTITEM_PPG* pFontItem = NULL; // Font already in the combobox if (FindString(-1, (LPCTSTR) pLF->lfFaceName) != CB_ERR) return CB_ERR; // allocate some memory for the FONTITEM_PPG structure TRY { pFontItem = new FONTITEM_PPG; } CATCH( CMemoryException, e ) { return CB_ERR; } END_CATCH ASSERT( pFontItem ); pFontItem->lf = *pLF; pFontItem->dwFontType = FontType; nEntry = AddString( (LPCTSTR) pFontItem->lf.lfFaceName ); if (nEntry == CB_ERR) delete pFontItem; else SetItemData( nEntry, (DWORD) pFontItem ); return nEntry; }
bool WIDGET_HOTKEY_LIST::TransferDataToControl() { Freeze(); DeleteAllItems(); m_hotkeys.clear(); for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index ) { // LoadSection pushes into m_hotkeys LoadSection( m_sections[sec_index].m_section ); wxASSERT( m_hotkeys.size() == sec_index + 1 ); wxString section_tag = *( m_sections[sec_index].m_section->m_SectionTag ); // Create parent tree item wxTreeListItem parent = AppendItem( GetRootItem(), m_sections[sec_index].m_name ); HOTKEY_LIST& each_list = m_hotkeys[sec_index]; HOTKEY_LIST::iterator hk_it; for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it ) { wxTreeListItem item = AppendItem( parent, wxEmptyString ); SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( &*hk_it, section_tag ) ); } Expand( parent ); } UpdateFromClientData(); Thaw(); return true; }
int TARowList::InsertItem( int _nItem, LPCTSTR _strName, void* _pData ) { int colNum = (int)m_pListColInfo.size(); ListCtrlItemInfo* pInfo = new ListCtrlItemInfo[colNum]; if (_nItem >= (int)m_pListItemInfo.size()) { m_pListItemInfo.push_back(pInfo); } else { m_pListItemInfo.insert(m_pListItemInfo.begin() + _nItem, pInfo); } for (int i=0; i<colNum; ++i) { pInfo[i].bEnable = m_pListColInfo[i]->bEnable; pInfo[i].bGrayed = m_pListColInfo[i]->bGrayed; } int res ; if (m_pListColInfo[0]->eType == LCDT_NO) { res = InsertItemWithNo(_nItem); } else { res = CListCtrl::InsertItem(_nItem, _strName); } SetItemData(res, (DWORD_PTR)_pData); return res; }
//*************************************************************************************** BOOL CBCGFontComboBox::Setup (int nFontType, BYTE nCharSet, BYTE nPitchAndFamily) { ASSERT_VALID (this); ASSERT (::IsWindow (m_hWnd)); if (m_bToolBarMode) { ASSERT (FALSE); return FALSE; } CleanUp (); CBCGToolbarFontCombo combo (0, (UINT)-1, nFontType, nCharSet, CBS_DROPDOWN, 0, nPitchAndFamily); for (int i = 0; i < combo.GetCount (); i++) { CString strFont = combo.GetItem (i); CBCGFontDesc* pFontDescrSrc = (CBCGFontDesc*) (DWORD_PTR) combo.GetItemData (i); ASSERT_VALID (pFontDescrSrc); if (FindStringExact (-1, strFont) <= 0) { CBCGFontDesc* pFontDescr = new CBCGFontDesc (*pFontDescrSrc); int iIndex = AddString (strFont); SetItemData (iIndex, (DWORD_PTR) pFontDescr); } } return TRUE; }
HTREEITEM EXTreeCtrl::CopyItem(HTREEITEM hItem, HTREEITEM htiNewParent, HTREEITEM htiAfter) { TV_INSERTSTRUCT tvstruct; HTREEITEM hNewItem; CString sText; // get information of the source item tvstruct.item.hItem = hItem; tvstruct.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; GetItem(&tvstruct.item); sText = GetItemText( hItem ); tvstruct.item.cchTextMax = sText.GetLength(); tvstruct.item.pszText = sText.LockBuffer(); // Insert the item at proper location tvstruct.hParent = htiNewParent; tvstruct.hInsertAfter = htiAfter; tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; hNewItem = InsertItem(&tvstruct); sText.ReleaseBuffer(); // Now copy item data and item state. SetItemData( hNewItem, GetItemData( hItem )); SetItemState( hNewItem, GetItemState( hItem, TVIS_STATEIMAGEMASK ), TVIS_STATEIMAGEMASK ); // ins.item.lParam = (LPARAM)(pItem); // Call virtual function to allow further processing in derived class // OnItemCopied( hItem, hNewItem ); return hNewItem; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CIconComboBox::InsertIcon( LPCTSTR pIconName, int ndx ) { // // create an icon from file // // NULL - no icons in file // 1 - not a proper icon file // HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), pIconName, 0 ); if( ( hIcon == ( HICON )1 ) || !hIcon ) return CB_ERR; // // insert the icon into the combo box -- returning the index // // CB_ERR - general error adding icon // CB_ERRSPACE - insufficient space necessary to add icon // int result = CComboBox::InsertString( ndx, pIconName ); if( ( result == CB_ERR ) || ( result == CB_ERRSPACE ) ) return result; // // associate the icon with the index // // CB_ERR - general error // result = SetItemData( ndx, ( DWORD )hIcon ); if( result == CB_ERR ) return result; // return the icon index return ndx; }
void FilterListCtrl::UpdateList() { DeleteAllItems(); CString clsid_str; CString guid_search_str(search_str); guid_search_str.Replace(_T("0X"), _T("")); const TCHAR delimiters[] = _T(" \t-,{}()=/;UL"); // remove commonly used C++ GUID delimiters and match by remaining hex digits for (int n=0; n<sizeof(delimiters)/sizeof(delimiters[0]); n++) guid_search_str.Remove(delimiters[n]); for (int i=0; i<filters.GetCount(); i++) { DSUtil::FilterTemplate &filter = filters[i]; if (CString(filter.name).MakeUpper().Find(search_str) < 0) { CLSIDToString(filter.clsid, clsid_str); clsid_str.Remove(_T('-')); // remove hex separators generated by CLSIDToString if (clsid_str.Find(guid_search_str) < 0) { continue; } } const int item = InsertItem(LVIF_PARAM | LVIF_TEXT, 0, filter.name, 0, 0, 0, (LPARAM)&filter); SetItemData(item, (DWORD_PTR)&filter); } }