当前位置: 首页>>代码示例>>C++>>正文


C++ CListBox::FindString方法代码示例

本文整理汇总了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;
}
开发者ID:isongbo,项目名称:MyCode,代码行数:28,代码来源:TCPServerDlg.cpp

示例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);
	}
}
开发者ID:devurandom,项目名称:shadowkeeper,代码行数:49,代码来源:PortraitsDlg.cpp

示例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));
			}
		}
	}
}
开发者ID:afrozm,项目名称:projects,代码行数:46,代码来源:Preferences.cpp

示例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);
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:19,代码来源:CreatePatchGroupDlg.cpp


注:本文中的CListBox::FindString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。