本文整理汇总了C++中CListBox::SetItemData方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::SetItemData方法的具体用法?C++ CListBox::SetItemData怎么用?C++ CListBox::SetItemData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CListBox
的用法示例。
在下文中一共展示了CListBox::SetItemData方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void KG3DAnimationContainer::FillAnimationList(CListBox& ListBox, enuFillListBoxType Type)
{
ListBox.ResetContent();
LPCTSTR pszName = NULL;
for(int i = 0; i < static_cast<int>(m_Clips.size()); i++)
{
switch(Type)
{
case ENUM_FILL_WITH_ANINAME:
{
m_Clips[i]->GetName(&pszName);
ListBox.InsertString(i, pszName);
ListBox.SetItemData(i, reinterpret_cast<DWORD_PTR>(m_Clips[i]));
break;
}
case ENUM_FILL_WITH_FILENAME:
{
m_Clips[i]->GetPathName(&pszName);
ListBox.InsertString(i, pszName);
ListBox.SetItemData(i, reinterpret_cast<DWORD_PTR>(m_Clips[i]));
break;
}
}
}
}
示例2: Init
//----------------------------------------------------------------------
void MapSizeDlg::Init()
{
CListBox* pListBox = (CListBox*)GetDlgItem( IDC_MAPSIZE );
int index = pListBox->AddString( "60x60" );
pListBox->SetItemData( index, 0 );
index = pListBox->AddString( "80x80" );
pListBox->SetItemData( index, 1 );
index = pListBox->AddString( "100x100" );
pListBox->SetItemData( index, 2 );
index = pListBox->AddString( "120x120" );
pListBox->SetItemData( index, 3 );
pListBox->SetCurSel( mapSize );
}
示例3: BuildList
void CLabelTypeDialog::BuildList(void)
{
int nType = IsDlgButtonChecked(IDC_LABEL_TYPE_LASER)
? CPaperInfo::PAPER_CutSheet
: CPaperInfo::PAPER_Continuous;
/*
// Get the name to match.
*/
CString csOldName;
if (m_pOldInfo != NULL)
{
csOldName = m_pOldInfo->GetName();
}
int nNewSel = 0;
CListBox* pList;
if ((pList = (CListBox*)GetDlgItem(IDC_LABEL_LIST)) != NULL)
{
pList->SetRedraw(FALSE);
pList->ResetContent();
int nLabels = m_List.Labels();
for (int nLabel = 0; nLabel < nLabels; nLabel++)
{
CLabelData* pLabel = m_List.Label(nLabel);
ASSERT(pLabel != NULL);
if (pLabel != NULL && pLabel->Type() == nType)
{
int nIndex = pList->AddString(pLabel->GetName());
if (nIndex >= 0)
{
pList->SetItemData(nIndex, (DWORD)pLabel);
if (pLabel->GetName() == csOldName)
{
nNewSel = nIndex;
}
}
}
}
/*
// Set the initial entry as necessary.
*/
if (pList->GetCount() > 0)
{
pList->SetCurSel(nNewSel);
OnSelchangeLabelList();
}
pList->SetRedraw(TRUE);
}
}
示例4: BuildList
void CPhotoProjectsTypeDlg::BuildList(void)
{
/*
// Get the name to match.
*/
CString csOldName;
if (m_pOldInfo != NULL)
{
csOldName = m_pOldInfo->GetName();
}
int nNewSel = 0;
CListBox* pList;
if ((pList = (CListBox*)GetDlgItem(IDC_PHOTOPROJECTS_LIST)) != NULL)
{
pList->SetRedraw(FALSE);
pList->ResetContent();
int nPhotoPrjs = m_List.PhotoProjects();
for (int nPhotoPrj = 0; nPhotoPrj < nPhotoPrjs; nPhotoPrj++)
{
CPhotoPrjData* pPhotoPrj = (CPhotoPrjData*)m_List.PhotoProject(nPhotoPrj);
ASSERT(pPhotoPrj != NULL);
int nIndex = pList->AddString(pPhotoPrj->m_pSubAreaData[0]->GetName());
if (nIndex >= 0)
{
pList->SetItemData(nIndex, (DWORD)pPhotoPrj);
if (pPhotoPrj->m_pSubAreaData[0]->GetName() == csOldName)
{
nNewSel = nIndex;
}
}
}
/*
// Set the initial entry as necessary.
*/
if (pList->GetCount() > 0)
{
pList->SetCurSel(nNewSel);
OnSelchangePhotoProjectsList();
}
pList->SetRedraw(TRUE);
}
}
示例5: GetPortraitList
void CPortraitsDlg::GetPortraitList(CListBox &lb, char chSize, int nWidth, int nHeight)
{
char szSearch[MAX_PATH+1];
char szPath[MAX_PATH+1];
char szFilename[MAX_PATH+1];
sprintf(szPath,"%s%s",(const char *)_strInstallPath,DIR_PORTRAITS);
sprintf(szSearch,"%s*%c.bmp",szPath,chSize);
WIN32_FIND_DATA fd;
HANDLE hFile = ::FindFirstFile(szSearch,&fd);
if (hFile == INVALID_HANDLE_VALUE)
return;
char szFile[MAX_PATH+1];
CFile file;
BMPTOP top;
int nIndex;
BOOL bFoundAnother = TRUE;
while(bFoundAnother)
{
strcpy(szFile,fd.cFileName);
bFoundAnother = ::FindNextFile(hFile,&fd);
if (strlen(szFile)-4 > 8)
continue;
sprintf(szFilename,"%s%s",szPath,szFile);
if (!file.Open(szFilename,CFile::modeRead|CFile::shareDenyNone|CFile::typeBinary))
continue;
if (file.Read(&top,sizeof(BMPTOP)) != sizeof(BMPTOP))
continue;
file.Close();
if (top.bih.biWidth != nWidth || top.bih.biHeight != nHeight)
continue;
szFile[strlen(szFile)-4] = '\x0';
// Make sure it isn't alreadyin the list. If it is, then there is a BMP called
// the same thing as one of hte internal resources.
if (lb.FindString(-1,szFile) != LB_ERR)
continue;
nIndex = lb.AddString(szFile);
lb.SetItemData(nIndex,0);
}
}
示例6: BuildList
void CEnvelopeTypeDialog::BuildList(void)
{
CListBox* pList;
if ((pList = (CListBox*)GetDlgItem(IDC_ENVELOPE_LIST)) != NULL)
{
/*
// Get the name to match.
*/
CString csOldName;
if (m_pOldInfo != NULL)
{
csOldName = m_pOldInfo->GetName();
}
int nNewSel = 0;
pList->SetRedraw(FALSE);
pList->ResetContent();
int nLabels = m_List.Labels();
for (int nLabel = 0; nLabel < nLabels; nLabel++)
{
CLabelData* pLabel = m_List.Label(nLabel);
ASSERT(pLabel != NULL);
if (pLabel != NULL)
{
int nIndex = pList->AddString(pLabel->GetName());
if (nIndex >= 0)
{
pList->SetItemData(nIndex, (DWORD)pLabel);
/*
// If the label matches the name coming in,
// remember its position.
*/
if (pLabel->GetName() == csOldName)
{
nNewSel = nIndex;
}
}
}
}
// Always start with the first label.
pList->SetCurSel(nNewSel);
pList->SetRedraw(TRUE);
OnSelchangeEnvelopeList(); // Do this by hand.
}
}
示例7: OnInitDialog
BOOL DlgGuardFlags::OnInitDialog()
{
CDialog::OnInitDialog();
CListBox* lb;
lb = (CListBox*)GetDlgItem(IDC_GUARD_FLAGS);
for(int i = 0; i < GuardBitCount(); i++)
{
lb->InsertString(i, guard_bits[i].name);
lb->SetItemData(i, guard_bits[i].bit);
}
SetFlags();
return TRUE;
}
示例8: OnRefresh
void CConnDlg :: OnRefresh()
{
CWysApp* pApp = (CWysApp*)AfxGetApp();
// clear listbox
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LSTCONN);
pListBox->ResetContent();
// iterate through sockets
// displaying connected items
for (INT i = 0, j = 0; i < MAXCONN; i++) {
if (pApp->pSockets[i]->State == CONNECTED) {
// set IP address
pListBox->AddString(pApp->pSockets[i]->IPAddress);
// set socket descriptor value
pListBox->SetItemData(j, pApp->pSockets[i]->m_hSocket);
j++;
}
}
return;
}
示例9: GetResourceList
void CPortraitsDlg::GetResourceList(CListBox &lb, char chSize, int nWidth, int nHeight)
{
CObList *pList;
if (!_infKey.GetResList(RESTYPE_BMP,pList))
return;
ASSERT(pList);
chSize = toupper(chSize);
int nIndex;
BMPTOP top;
CResInfo *pResInfo;
CInfBifFile *pBmpFile;
POSITION pos = pList->GetHeadPosition();
while(pos)
{
pResInfo = (CResInfo*)pList->GetNext(pos);
// According to the docs, all large portraits end with an 'L'. I'm going to
// assume all the resources follow this rule.
if (pResInfo->strName.IsEmpty() || toupper(pResInfo->strName.GetAt(pResInfo->strName.GetLength()-1)) != chSize)
continue;
// Make sure the size is agreeable.
pBmpFile = _infKey.GetBifFile(pResInfo);
if (!pBmpFile || !pBmpFile->IsValid())
continue;
if (pBmpFile->GetData(pResInfo,&top,sizeof(BMPTOP)) == -1)
continue;
if (top.bih.biWidth != nWidth || top.bih.biHeight != nHeight)
continue;
nIndex = lb.AddString(pResInfo->strName);
lb.SetItemData(nIndex,1); // Set to 1 for in-game resources.
}
}
示例10: DoDataExchange
void CChooseKeyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChooseKeyDlg)
DDX_Control(pDX, IDC_FAVOURITES, m_favourites);
//}}AFX_DATA_MAP
if (!pDX->m_bSaveAndValidate)
{
CListBox *pBox = (CListBox *)GetDlgItem(IDC_FAVOURITES);
// We are loading the dialog
CSpellEdApp *pApp = (CSpellEdApp *)AfxGetApp();
CLinkListNode<FK_FAVOURITE *> *pNode = pApp->GetKeyFavourites()->GetHead();
while (pNode)
{
int nIndex = pBox->AddString(pNode->m_Data->m_sName);
pBox->SetItemData(nIndex, (DWORD)pNode->m_Data);
pNode = pNode->m_pNext;
}
m_favourites.SetCurSel(0);
}
else
{
// We are unloading the dialog
int nCurSel = m_favourites.GetCurSel();
if (nCurSel != LB_ERR)
{
m_pFav = (FK_FAVOURITE *)m_favourites.GetItemData(nCurSel);
}
}
}
示例11: GetOPCServers
BOOL OPCServerDlg::GetOPCServers(LPTSTR node)
{
CListBox* pList = (CListBox*)GetDlgItem( IDC_SERVER_LIST );
USES_CONVERSION;
CWaitCursor wait;
ASSERT_VALID(pList);
pList->ResetContent();
// New 2.0 method using component categories
IOPCServerList* pServers=NULL;
COSERVERINFO si;
MULTI_QI qi;
si.dwReserved1 = 0;
si.pwszName = NULL;
if( node && node[0] != 0 )
si.pwszName = T2OLE(node);
si.pAuthInfo = NULL;
si.dwReserved2 = 0;
qi.pIID = &IID_IOPCServerList;
qi.pItf = NULL;
qi.hr = 0;
HRESULT hr = CoCreateInstanceEx(CLSID_OPCServerList, NULL, CLSCTX_ALL, &si, 1, &qi);
if (FAILED(hr) || FAILED(qi.hr))
{
CString msg(_T("Error connecting to OPC 2.0 Server Browser."));
if( !m_Node.IsEmpty() )
msg.Format(_T("Error connecting to OPC 2.0 Server Browser on %s."), (LPCTSTR)m_Node);
if( hr == REGDB_E_CLASSNOTREG )
{
CString msg(_T("Please install the OPC 2.0 Components."));
if( !m_Node.IsEmpty() )
msg.Format(_T("Please install the OPC 2.0 Components on %s."), (LPCTSTR)m_Node);
}
if( FAILED(hr) )
theDoc->ReportError(msg, hr);
else
theDoc->ReportError(msg, qi.hr);
}
else
{
pServers = (IOPCServerList*)qi.pItf;
IEnumGUID *pEnumGUID=NULL;
hr = pServers->EnumClassesOfCategories(1, &m_catid, 1, &m_catid, &pEnumGUID);
if( SUCCEEDED(hr) )
{
unsigned long count;
CLSID clsid[NEXT_COUNT];
do
{
hr = pEnumGUID->Next(NEXT_COUNT, clsid, &count);
for( ULONG index=0; index<count; index++ )
{
LPOLESTR pszProgID;
LPOLESTR pszUserType;
HRESULT hr2 = pServers->GetClassDetails(clsid[index], &pszProgID, &pszUserType);
if (SUCCEEDED(hr2))
{
OPCServerInfo* pServerInfo = new OPCServerInfo(pszProgID, pszUserType, clsid[index] );
m_Servers.AddTail( pServerInfo );
CString name;
name.Format( _T("%s (%s)"),
(LPCTSTR)pServerInfo->m_ProgID,
(LPCTSTR)pServerInfo->m_Description );
int pos = pList->AddString( name );
pList->SetItemData( pos, (DWORD)pServerInfo );
if( m_Server == pServerInfo->m_ProgID )
pList->SetCurSel(pos);
CoTaskMemFree(pszProgID);
CoTaskMemFree(pszUserType);
}
}
}
while ( hr==S_OK );
pEnumGUID->Release();
pServers->Release();
return TRUE;
}
else // hr failed
{
CString msg(_T("EnumClassesOfCategories failed:"));
theDoc->ReportError(msg, hr);
}
pServers->Release();
}
// Old 1.0 method: search the registry for OPC entries
if( m_catid != CATID_OPCDAServer10 )
return FALSE;
HKEY hk = HKEY_CLASSES_ROOT;
//.........这里部分代码省略.........
示例12: FillListBoxes
void CAnimPicker::FillListBoxes()
{
// fill in the enum list boxes...
//
CListBox* boxLegs = (CListBox*)GetDlgItem(IDC_LIST_LEGS);
CListBox* boxTorso= (CListBox*)GetDlgItem(IDC_LIST_TORSO);
CListBox* boxBoth = (CListBox*)GetDlgItem(IDC_LIST_BOTH);
CListBox* boxFace = (CListBox*)GetDlgItem(IDC_LIST_FACE);
CListBox* boxVM = (CListBox*)GetDlgItem(IDC_LIST_VM);
boxLegs->ResetContent();
boxTorso->ResetContent();
boxBoth->ResetContent();
boxFace->ResetContent();
boxVM->ResetContent();
CModel* theModel = ghAssimilateView->GetDocument()->GetCurrentUserSelectedModel();
ASSERT(theModel);
if (theModel)
{
for (int i=0; ; i++)
{
LPCSTR p = ((CAssimilateApp*)AfxGetApp())->GetEnumEntry(i);
if (!p)
break;
CString string = p;
if (theModel->AnimEnumInUse(p))
{
if (m_bFilterOutUsed)
continue;
string.Insert(0,sEnumUsedString);
}
if (IsEnumSeperator(p))
{
string = StripSeperatorStart(p);
string.Insert(0,sEnumSeperatorString_Prefix);
string+=sEnumSeperatorString_Suffix;
}
CListBox* listBoxPtr = NULL;
switch (GetEnumTypeFromString(p)) // note (p), *not* (string)
{
case ET_BOTH: listBoxPtr = boxBoth; break;
case ET_TORSO: listBoxPtr = boxTorso; break;
case ET_LEGS: listBoxPtr = boxLegs; break;
case ET_FACE: listBoxPtr = boxFace; break;
case ET_VM: listBoxPtr = boxVM; break;
default: ASSERT(0); break;
}
if (listBoxPtr)
{
// keep an index to the original enum for comment-diving reasons...
//
int iIndex = listBoxPtr->InsertString(-1,string);
listBoxPtr->SetItemData(iIndex,(DWORD)p);
}
}
}
}
示例13: Init
//----------------------------------------------------------------------
void MapSizeDlg::Init()
{
CListBox* pListBox = (CListBox*)GetDlgItem( IDC_MAPSIZE );
int index = pListBox->AddString( "60x60" );
pListBox->SetItemData( index, 0 );
index = pListBox->AddString( "80x80" );
pListBox->SetItemData( index, 1 );
index = pListBox->AddString( "100x100" );
pListBox->SetItemData( index, 2 );
index = pListBox->AddString( "120x120" );
pListBox->SetItemData( index, 3 );
//magic 21022011 begin
index = pListBox->AddString( "140x140" );
pListBox->SetItemData( index, 4 );
index = pListBox->AddString( "160x160" );
pListBox->SetItemData( index, 5 );
//magic 23022011 begin
index = pListBox->AddString( "180x180" );
pListBox->SetItemData( index, 6 );
index = pListBox->AddString( "200x200" );
pListBox->SetItemData( index, 7 );
//magic 23022011 end
//magic 24032012 begin
index = pListBox->AddString( "220x220" );
pListBox->SetItemData( index, 8 );
index = pListBox->AddString( "240x240" );
pListBox->SetItemData( index, 9 );
index = pListBox->AddString( "260x260" );
pListBox->SetItemData( index, 10 );
index = pListBox->AddString( "280x280" );
pListBox->SetItemData( index, 11 );
//magic 24032012 end
//magic 21022011 end
pListBox->SetCurSel( mapSize );
}