本文整理汇总了C++中CItemInfo类的典型用法代码示例。如果您正苦于以下问题:C++ CItemInfo类的具体用法?C++ CItemInfo怎么用?C++ CItemInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CItemInfo类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: STEPGetFileInfo
extern "C" STEP_API void WINAPI STEPGetFileInfo(int nItem, FILE_INFO* info)
{
CSuperGridCtrl::CTreeItem *pItem = STEP_List->GetTreeItem(nItem);
CItemInfo *pItemInfo = STEP_List->GetData(pItem);
FILE_MP3 *fileMP3 = STEP_List->m_pDoc->GetListMP3((int)pItemInfo->GetLParam());
info->pFileMP3 = fileMP3;
}
示例2: GetTreeItem
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: ASSERT
//helper function to copy CItemInfo used when drag/drop you must override this this function to suit your own CItemInfo class
CItemInfo* CMySuperGrid::CopyData(CItemInfo* lpSrc)
{
ASSERT(lpSrc!=NULL);
CItemInfo* lpDest = new CItemInfo;
//well okay I put all the copy thing in one function, located in CItemInfo class,
//so you should check out this function, remember to modify this function each time you add new data to CItemInfo class.
lpDest->CopyObjects(lpSrc);
return lpDest;
}
示例4: _T
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;
}
}
}
}
示例5: GetData
//override
void CMySuperGrid::OnUpdateListViewItem(CTreeItem* lpItem, LV_ITEM *plvItem)
{
//put some extra validation here
CString str = (CString)plvItem->pszText;
if(!str.Compare(_T("Bugs: Impossible")))
{
str+=_T(" (selfconfidence allright)");//that's valid enough :§)
CItemInfo *lp = GetData(lpItem);
if(lp!=NULL)
{
if(plvItem->iSubItem==0)
lp->SetItemText(str);
else //subitem data
lp->SetSubItemText(plvItem->iSubItem-1, str);
UpdateData(lpItem, lp); //update internal nodes
}
SetItemText(plvItem->iItem, plvItem->iSubItem, str.GetBuffer(1));
}
else
CSuperGridCtrl::OnUpdateListViewItem(lpItem, plvItem);
}
示例6: CItemInfo
// -----------------------------------------------------------//
// Function : Add_MS_DOS_Stub
// Param : CHAR* pBuffer
// CMySuperGrid& m_ListGrid
// CTreeItem_* parentItem
// Return : CTreeItem_*
// Comment :
// -----------------------------------------------------------//
CTreeItem_* CPEShowView::Add_MS_DOS_Stub(CHAR* pBuffer, DWORD dwAddressBase, CMySuperGrid& m_ListGrid,CTreeItem_* parentItem)
{
if(pBuffer == NULL || parentItem == NULL)
{
return NULL;
}
CItemInfo* dosStubItem = new CItemInfo();
dosStubItem->SetImage(0);
dosStubItem->SetItemText("MS_DOS_Stub");
CString str;
str.Format(_T("%08x"), dwAddressBase);
dosStubItem->AddSubItemText(str);
dosStubItem->AddSubItemText("-");
dosStubItem->AddSubItemText("-");
dosStubItem->AddSubItemText("-");
dosStubItem->AddSubItemText("MS_DOS_Stub");
CTreeItem_* pDosTreeItem = m_ListGrid.InsertItem(parentItem, dosStubItem);
if(pDosTreeItem == NULL)
{
return NULL;
}
return pDosTreeItem;
}
示例7: GetNextItem
BOOL CMySuperGrid::OnVkReturn()
{
BOOL bResult=FALSE;
int iItem = GetNextItem( -1, LVNI_ALL | LVNI_SELECTED);
if( GetCurSubItem() != -1 && iItem != -1)
{
CTreeItem*pSelItem = GetTreeItem(iItem);
if(pSelItem!=NULL)
{
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int iSubItem = Header_OrderToIndex(pHeader->m_hWnd, GetCurSubItem());
CItemInfo* pInfo = GetData(pSelItem);
CItemInfo::CONTROLTYPE ctrlType;
if(pInfo->GetControlType(iSubItem-1, ctrlType))
{
switch(ctrlType)
{
/*put in your own control here*/
case pInfo->CONTROLTYPE::datecontrol:break;
case pInfo->CONTROLTYPE::spinbutton:break;
case pInfo->CONTROLTYPE::dropdownlistviewwhatevercontrol:break;
case pInfo->CONTROLTYPE::combobox:
{
CStringList* list=NULL;
pInfo->GetListData(iSubItem-1, list);
CComboBox * pList = ShowList(iItem, iSubItem, list);
bResult=TRUE; //I'll handle it from here
}break;
default:break;
}
}
}
}
return bResult;
}
示例8: FindItem
CTypeInfo* CStreamPathHookBase::FindType(const CObjectStack& stk)
{
CItemInfo* item = FindItem(stk);
return item ? const_cast<CTypeInfo*>(item->GetTypeInfo()) : 0;
}
示例9: STEPGetSubItemText
extern "C" STEP_API const wchar_t* WINAPI STEPGetSubItemText(int nItem, int nColumn)
{
CSuperGridCtrl::CTreeItem *pItem = STEP_List->GetTreeItem(nItem);
CItemInfo *pItemInfo = STEP_List->GetData(pItem);
return pItemInfo->GetSubItem(nColumn-1);
}
示例10: 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);
}
示例11: Search
//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"));
}
示例12: GetRootHeadPosition
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
}
示例13: useItem
void CPlayer::useItem(int itemID)
{
std::string machineName = this->getMachineName();
size_t idx = machineName.find("Server");
if(idx != std::string::npos) {
// Server端處理
CItemInfo* pItemInfo = CItem::getInfo(itemID);
if(pItemInfo == NULL)
return;
if(pItemInfo->getClassType() == WEAPON) {
CWeaponInfo *pWp = (CWeaponInfo*) pItemInfo;
if(this->getLevel() >= pWp->getLevel()) {
if(ONE_HAND == pWp->getWield())
wearToEquipSlot(MAIN_HAND, itemID);
else if(TWO_HAND == pWp->getWield())
wearToEquipSlot(OFF_HAND, itemID);
}
}
else if(pItemInfo->getClassType() == ARMOR) {
CArmorInfo *pAm = (CArmorInfo*) pItemInfo;
if(this->getLevel() >= pAm->getLevel()) {
if(CLOTHES == pAm->getWear())
wearToEquipSlot(CHEST, itemID);
else if(BELTS == pAm->getWear())
wearToEquipSlot(BELT, itemID);
else if(PANTS == pAm->getWear())
wearToEquipSlot(LEGS, itemID);
else if(PAULDRONS == pAm->getWear())
wearToEquipSlot(SHOULDER, itemID);
else if(GLOVES == pAm->getWear())
wearToEquipSlot(GLOVE, itemID);
else if(BOOTS == pAm->getWear())
wearToEquipSlot(BOOT, itemID);
}
}
else if(pItemInfo->getClassType() == CONSUMABLE) {
CConsumableInfo *pConsumableInfo = (CConsumableInfo *)pItemInfo;
if(this->getLevel() >= pConsumableInfo->getLevel()) {
if(pConsumableInfo->getEffect() == EDIBLE_SKILL)
addSkill(pConsumableInfo->getMuch()); // 學習某項技能
else if(pConsumableInfo->getEffect() == EDIBLE_HP) {
if(getHPMax() == getHP())
return;
addHP(pConsumableInfo->getMuch()); // 補血
// Todo: 藥水是否有CD時間
}
else if(pConsumableInfo->getEffect() == EDIBLE_MP) {
if(getMP() == getMPMax())
return;
addMP(pConsumableInfo->getMuch()); // 補魔
// Todo: 藥水是否有CD時間
}
else
return;
// 背包物品減一
m_pBackpack->removeItem(itemID);
}
}
}
else {
// Client端處理
}
}
示例14: va_start
//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;
}