本文整理汇总了C++中CListBox::FindString方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::FindString方法的具体用法?C++ CListBox::FindString怎么用?C++ CListBox::FindString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CListBox
的用法示例。
在下文中一共展示了CListBox::FindString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnClientConnect
//客户端连接断开消息函数
LONG CTCPServerDlg::OnClientConnect(WPARAM wParam,LPARAM lParam)
{
int iIndex;
TCHAR *szAddress = (TCHAR*)lParam;
CString strAddrss = szAddress;
CListBox * pLstConn = (CListBox*)GetDlgItem(IDC_LST_CONN);
ASSERT(pLstConn != NULL);
if (wParam == 0)
{
pLstConn->AddString(strAddrss + _T("建立连接"));
}
else
{
iIndex = pLstConn->FindString(iIndex,strAddrss + _T("建立连接"));
if (iIndex != LB_ERR)
{
pLstConn->DeleteString(iIndex);
}
}
//释放内存
delete[] szAddress;
szAddress = NULL;
return 0;
}
示例2: 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);
}
}
示例3: OnBnClickedOk
void CPreferences::OnBnClickedOk()
{
// Call the funtion
/// check which check box is sleated
// Load/Save
if (IsDlgButtonChecked(IDC_RADIO_SAVE)) { // Save
CString prefName;
GetDlgItemText(IDC_EDIT_PREFERENCE_NAME, prefName);
CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
int indexInListBox = listBox->FindString(-1, prefName);
if (indexInListBox >= 0) { // Already has this preference name
if (MessageBox(prefName + _T(" already exists.\nDo you want to overwrite."),
0, MB_YESNO) == IDNO) {
CEdit *pEdit((CEdit*)GetDlgItem(IDC_EDIT_PREFERENCE_NAME));
pEdit->SetFocus();
pEdit->SetSel(0, -1);
return;
}
}
SavePreference(prefName);
listBox->AddString(prefName);
((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF))->AddString(prefName);
}
else if (IsDlgButtonChecked(IDC_RADIO_LOAD)) { // Load
CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
int curSel = listBox->GetCurSel();
if (curSel >= 0) { // User has selected
CString prefName;
listBox->GetText(curSel, prefName);
LoadPreference(prefName);
}
}
else if (IsDlgButtonChecked(IDC_RADIO_DELETE)) { // Delete
CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
int curSel = listBox->GetCurSel();
if (curSel >= 0) { // User has selected
CString prefName;
listBox->GetText(curSel, prefName);
if (DeletePreference(prefName)) {
listBox->DeleteString(curSel);
CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
pComboBox->DeleteString(pComboBox->FindString(1, prefName));
}
}
}
}
示例4: OnBnClickedButtonAddgroup
void CCreatePatchGroupDlg::OnBnClickedButtonAddgroup()
{
// TODO: Add your control notification handler code here
CString strGroupID;
GetDlgItemText(IDC_EDIT_GROUP_ID, strGroupID);
if (strGroupID.IsEmpty())
return;
SetDlgItemText(IDC_EDIT_GROUP_ID, _T(""));
CListBox* pList = (CListBox*)GetDlgItem(IDC_LIST_GROUPLIST);
if (LB_ERR != pList->FindString(-1, strGroupID))
{
return;
}
pList->AddString(strGroupID);
}