本文整理汇总了C++中CItemInfo::GetItemText方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemInfo::GetItemText方法的具体用法?C++ CItemInfo::GetItemText怎么用?C++ CItemInfo::GetItemText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemInfo
的用法示例。
在下文中一共展示了CItemInfo::GetItemText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HowToLoopThroughAllItems_if_we_wanted_to_print_them_or_what_ever
void CMySuperGrid::HowToLoopThroughAllItems_if_we_wanted_to_print_them_or_what_ever(CDC *pDC)
{
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int cy = tm.tmHeight + tm.tmExternalLeading;
int nLineY=0;
nLineY+=cy;
pDC->TextOut(10, nLineY, _T("GIVE ME A BREAK YOU KNOW PRINT PREVIEW IS NOT THE ISSUE HERE"));
nLineY+=cy;
nLineY+=cy;
int nIndex = GetNextItem(-1, LVNI_ALL | LVNI_SELECTED); //print from current node
if(nIndex!=-1)
{
//GetHeadPosition
POSITION pos = GetRootHeadPosition();
while(pos != NULL)
{
CTreeItem *pParent =(CTreeItem*)GetNextRoot(pos);
CTreeItem *pItem = pParent;
CItemInfo* lp = GetData(pParent);
CString strData = lp->GetItemText();
strData+='\t';
nLineY+=cy;
for(int nCol=0; nCol < lp->GetItemCount(); nCol++)
{
CString str = lp->GetSubItem(nCol);
strData+=str;
strData+='\t';
}
pDC->TabbedTextOut(10,nLineY,strData,strData.GetLength(), 0, NULL, 0);
nLineY+=cy;
//GetNext ....loop through all children
for(;;)
{
CTreeItem *pCur = GetNext(pParent,pItem, TRUE, FALSE/*regardless of the item are hidden or not*/);
if(!IsChildOf(pParent, pCur))
break;
else
if(pCur==pItem)
break;
CItemInfo* lp = GetData(pCur);
CString strData = lp->GetItemText();
strData+='\t';
for(int nCol=0; nCol < lp->GetItemCount(); nCol++)
{
CString str = lp->GetSubItem(nCol);
strData+=str;
strData+='\t';
}
pDC->TabbedTextOut(10,nLineY,strData,strData.GetLength(), 0, NULL, 0);
nLineY+=cy;
pItem=pCur;
}
}
}
}
示例2: OnItemLButtonDown
BOOL CMySuperGrid::OnItemLButtonDown(LVHITTESTINFO& ht)
{
if(ht.iItem!=-1)
{
#ifdef _WHAT_EVER_
CTreeItem*pSelItem = GetTreeItem(ht.iItem);
if(pSelItem!=NULL)
{
CItemInfo* pInfo = GetData(pSelItem);
if((ht.iSubItem==0) && (pInfo->GetItemText()==CString(_T("Hello World"))))
{
AfxMessageBox("no can do buddy");
return 0;
}
for(int i=0;i<pInfo->GetItemCount(); i++)
{
if(i==ht.iSubItem-1)
{
CString str=pInfo->GetSubItem(i);
if(str == CString(_T("Ethan Hunt")))
{
AfxMessageBox("Tom Cruise\nliked him in a few good men");
return 0;
}
}
}
}
#endif
}
return 1;
}
示例3: SearchEx
//another search thing
CMySuperGrid::CTreeItem* CMySuperGrid::SearchEx(CTreeItem *pStartPosition, CString strItem)
{
CItemInfo* lp = GetData(pStartPosition);
//if(lp->GetCheck()) another condition here maybe
CString strData = lp->GetItemText();
if(strData==strItem)
{
return pStartPosition;
}
const int nChildren = NumChildren(pStartPosition);
if (nChildren > 0)
{
POSITION pos = GetHeadPosition(pStartPosition);
while (pos)
{
CTreeItem *pChild = GetNextChild(pStartPosition, pos);
CItemInfo* lp = GetData(pChild);
CString strData = lp->GetItemText();
if(strData==strItem)
{
return pChild;
}
}
}
POSITION pos = GetHeadPosition(pStartPosition);
while (pos)
{
CTreeItem *pChild = GetNextChild(pStartPosition, pos);
CItemInfo* lp = GetData(pChild);
CString strData = lp->GetItemText();
if(strData==strItem)
{
return pChild;
}
pChild = SearchEx(pChild, strItem);
if(pChild!=NULL)
return pChild;
}
return NULL;
}
示例4: HowToInsertItemsAfterTheGridHasBeenInitialized
//HOWTO:
void CMySuperGrid::HowToInsertItemsAfterTheGridHasBeenInitialized(int nIndex, const CString& str)
{
CTreeItem *pSelItem = GetTreeItem(nIndex);
if(pSelItem != NULL)
{
SetRedraw(0);
BOOL bUpdate = FALSE;
if(!IsCollapsed(pSelItem))
bUpdate = TRUE;//Children are expanded, want to see update right away if not no visual update
CItemInfo* lpRelative = new CItemInfo();
lpRelative->SetItemText(str);
lpRelative->AddSubItemText(_T("I am"));
lpRelative->AddSubItemText(_T("now"));
lpRelative->AddSubItemText(_T("going to insert"));
lpRelative->AddSubItemText(_T("some items"));
CTreeItem* pParent = InsertItem(pSelItem, lpRelative, bUpdate);
for(int i=0; i < GetNumCol(); i++)
{
CItemInfo* lpItemInfo = new CItemInfo();
CString strItem;
strItem.Format(_T("Item %d"), i);
//add items text
lpItemInfo->SetItemText(strItem);
//add subitem text
for(int y=0;y < GetNumCol()-1; y++)
{
CString str;
str.Format(_T("SubItem %d of %s"), y, lpItemInfo->GetItemText());
lpItemInfo->AddSubItemText(str);
}
//set combobox in last col
lpItemInfo->SetControlType(lpItemInfo->CONTROLTYPE::combobox, GetNumCol()-2);
CStringList list;
for(int x = 0; x < 3; x++)
{
CString str;
str.Format("ListItem %d",x);
list.AddTail(str);
}
lpItemInfo->SetListData(GetNumCol()-2, &list);
InsertItem(pParent, lpItemInfo);
}
SetRedraw(1);
InvalidateRect(NULL);
UpdateWindow();
}
}
示例5: _DeleteAll
void CMySuperGrid::_DeleteAll()
{
DeleteAll();//call CSuperGridCtrl::DeleteAll();
//add some new data
CItemInfo* lp = new CItemInfo();
lp->SetImage(4);
//add item text
lp->SetItemText(_T("New data"));
//Create root item
CTreeItem * pRoot = InsertRootItem(lp);//previous we call CreateTreeCtrl(lp)
if( pRoot == NULL )
return;
//insert items
int nCol = GetNumCol();
for(int i=0; i < nCol; i++)
{
CItemInfo* lpItemInfo = new CItemInfo();
CString strItem;
strItem.Format(_T("Item %d"),i);
//add items text
lpItemInfo->SetItemText(strItem);
//add subitem text
for(int y=0;y < nCol-1; y++)
{
CString str;
str.Format(_T("subItem %d of %s"),y,lpItemInfo->GetItemText());
lpItemInfo->AddSubItemText(str);
lpItemInfo->AddSubItemText(str);
}
//insert the iteminfo with ParentPtr
CTreeItem* pParent = InsertItem(pRoot, lpItemInfo);
//other nodes
if(i%nCol)
{
CTreeItem* pParent1=NULL;
CTreeItem* pParent2=NULL;
for(int x=0; x < nCol; x++)
{
CItemInfo* lpItemInfo = new CItemInfo();
CString strItem;
strItem.Format(_T("Item %d"),x);
lpItemInfo->SetItemText(strItem);
for(int z=0; z < nCol-1; z++)
{
CString str;
str.Format(_T("subItem %d of %s"),z, lpItemInfo->GetItemText());
lpItemInfo->AddSubItemText(str);
}
pParent1 = InsertItem(pParent, lpItemInfo);
}
}
}
//expand one level
Expand(pRoot, 0 /*listview index 0*/);
UINT uflag = LVIS_SELECTED | LVIS_FOCUSED;
SetItemState(0, uflag, uflag);
}
示例6: Search
//this is just one way to search items...strItem must match and then all subitems must be
//a match before returning the node
//the search function here search all nodes regardless if collapsed or expanded
CMySuperGrid::CTreeItem* CMySuperGrid::Search(CString strItem,...)
{
if(!GetItemCount())
return NULL;
va_list args;
va_start(args, strItem);
int nCount=0;
for(;;)
{
LPCTSTR lpsz = va_arg(args, LPCTSTR);
if(lpsz==NULL)
break;
nCount++;
}
POSITION pos = GetRootHeadPosition();
while(pos != NULL)
{
CTreeItem *pParent = (CTreeItem*)GetNextRoot(pos);
CTreeItem *pItem = pParent;
CItemInfo* lp = GetData(pParent);
CString strData = lp->GetItemText();
if(strData==strItem)//must be a match before going further...suit you self
{
va_start(args, strItem);
int nResult=0;
for(int i=0; i<nCount;i++)
{
LPCTSTR lpsz = va_arg(args, LPCTSTR);
for(int nCol=0; nCol < lp->GetItemCount(); nCol++)
{
CString str = lp->GetSubItem(nCol);
if(!str.CompareNoCase(lpsz))
{
nResult++;
break;
}
}
}
va_end(args);
if(nCount==nResult)//all args was found return node
return pParent;
}
//GetNext ....loop through all children
for(;;)
{
CTreeItem *pCur = GetNext(pParent, pItem, TRUE, FALSE/*regardless of the item are hidden or not, set to TRUE if only visible items must be included in the search*/);
if(!IsChildOf(pParent, pCur))
break;
else
if(pCur==pItem)
break;
CItemInfo* lp = GetData(pCur);
CString strData = lp->GetItemText();
if(strData==strItem)//must be a match before going further
{
va_start(args, strItem);
int nResult=0;
for(int i=0; i<nCount;i++)
{
LPCTSTR lpsz = va_arg(args, LPCTSTR);
for(int nCol=0; nCol < lp->GetItemCount(); nCol++)
{
CString str = lp->GetSubItem(nCol);
if(!str.CompareNoCase(lpsz))
{
nResult++;
break;
}
}
}
va_end(args);
if(nCount==nResult)//all args was found return node
return pCur;
}
pItem=pCur;//next;
}
}
return NULL;
}
示例7: HowToSearch_I_am_using_hardcoded_values_here_cause_I_am_tired_now
//HOWTO: Search nodeptr that have a specific item and subitems also shows you how to select the node and delete it
void CMySuperGrid::HowToSearch_I_am_using_hardcoded_values_here_cause_I_am_tired_now(void)
{
//one Item and two Subitems
CTreeItem *pNode = Search(__T("Hello World"),_T("Happy"),_T("Programming"),NULL);
if(pNode!=NULL)
{
CItemInfo *pInfo = GetData(pNode);
AfxMessageBox(_T("Found Item ") + pInfo->GetItemText());
}
else AfxMessageBox(_T("not found"));
//one Item and one Subitem
CTreeItem *pNode1 = Search(_T("Mission: Impossible"),_T("Allan Nielsen"),NULL);
if(pNode1!=NULL)
{
CItemInfo *pInfo = GetData(pNode1);
AfxMessageBox(_T("Found Item ") + pInfo->GetItemText());
}
else AfxMessageBox(_T("not found"));
//one Item and one Subitem
CTreeItem *pNode2 = Search(_T("Training Agent"),_T("Mr. Bean"),NULL);
if(pNode2!=NULL)
{
CItemInfo *pInfo = GetData(pNode2);
AfxMessageBox(_T("Found Item") + pInfo->GetItemText());
}
else AfxMessageBox(_T("not found"));
CTreeItem *pNode3 = Search(_T("BC"),NULL);
if(pNode3!=NULL)
{
CItemInfo *pInfo = GetData(pNode3);
AfxMessageBox(_T("Found Item ") + pInfo->GetItemText());
int nIndex = SelectNode(pNode3);
if(nIndex!=-1)
if(AfxMessageBox(_T("Do you want to delete it"),MB_OKCANCEL)==IDOK)
DeleteItemEx(pNode3, nIndex);
}
else AfxMessageBox(_T("not found"));
CTreeItem *pItem = NULL;
POSITION pos = GetRootHeadPosition();
while(pos != NULL)
{
CTreeItem * pRoot = (CTreeItem*)GetNextRoot(pos);
pItem = SearchEx(pRoot, "AB");
if(pItem!=NULL)
{
CItemInfo *pInfo = GetData(pItem);
AfxMessageBox(_T("Found Item ") + pInfo->GetItemText());
int nIndex = SelectNode(pItem);
if(nIndex!=-1)
if(AfxMessageBox(_T("Do you want to delete it"),MB_OKCANCEL)==IDOK)
DeleteItemEx(pItem, nIndex);
}
}
if( pItem == NULL )
AfxMessageBox(_T("not found"));
}
示例8: HowToLoopThroughAllItems_that_has_a_checkmark_and_print_them_or_what_ever
void CMySuperGrid::HowToLoopThroughAllItems_that_has_a_checkmark_and_print_them_or_what_ever(CDC *pDC)
{
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int cy = tm.tmHeight + tm.tmExternalLeading;
int nLineY=0;
nLineY+=cy;
pDC->TextOut(10,nLineY,_T("GIVE ME A BREAK YOU KNOW PRINT PREVIEW IS NOT THE ISSUE HERE"));
nLineY+=cy;
nLineY+=cy;
if(!GetItemCount())
return;
int nIndex=0;//has to be the root
if(nIndex!=-1)
{
//do a GetHeadPosition
POSITION pos = GetRootHeadPosition();
while(pos != NULL)
{
CTreeItem *pParent = (CTreeItem*)GetNextRoot(pos);
CTreeItem *pItem = pParent;
CItemInfo* lp = GetData(pParent);
if(lp->GetCheck())//very hard :)=
{
CString strData=lp->GetItemText();
strData+='\t';
nLineY+=cy;
for(int nCol=0; nCol < lp->GetItemCount(); nCol++)
{
CString str = lp->GetSubItem(nCol);
strData+=str;
strData+='\t';
}
pDC->TabbedTextOut(10,nLineY,strData,strData.GetLength(), 0, NULL, 0);
nLineY+=cy;
}
//GetNext ....loop through all children
for(;;)
{
CTreeItem *pCur = GetNext(pParent, pItem, TRUE, FALSE/*regardless of the item are hidden or not*/);
if(!IsChildOf(pParent, pCur))
break;
else
if(pCur==pItem)
break;
CItemInfo* lp = GetData(pCur);
if(lp->GetCheck())
{
CString strData = lp->GetItemText();
strData+='\t';
for(int nCol=0; nCol < lp->GetItemCount(); nCol++)
{
CString str = lp->GetSubItem(nCol);
strData+=str;
strData+='\t';
}
pDC->TabbedTextOut(10,nLineY,strData,strData.GetLength(), 0, NULL, 0);
nLineY+=cy;
}
pItem=pCur;
}
}//while
}//if
}