本文整理汇总了C++中CListBox::AddString方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::AddString方法的具体用法?C++ CListBox::AddString怎么用?C++ CListBox::AddString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CListBox
的用法示例。
在下文中一共展示了CListBox::AddString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayDMOTypeInfo
void DisplayDMOTypeInfo(const GUID *pCLSID,
ULONG& ulNumInputsSupplied, CListBox& ListInputTypes,
ULONG& ulNumOutputsSupplied, CListBox& ListOutputTypes)
{
const int NUM_PAIRS=20;
HRESULT hr;
DMO_PARTIAL_MEDIATYPE aInputTypes[NUM_PAIRS]={0},
aOutputTypes[NUM_PAIRS]={0};
ULONG ulNumInputTypes=NUM_PAIRS, ulNumOutputTypes=NUM_PAIRS, i;
TCHAR szCLSID[128];
// Read type/subtype information
hr = DMOGetTypes(
*pCLSID,
ulNumInputTypes, &ulNumInputsSupplied, aInputTypes,
ulNumOutputTypes, &ulNumOutputsSupplied, aOutputTypes);
if (FAILED(hr))
return;
// Show input type/subtype pairs
for (i=0; i<ulNumInputsSupplied; i++)
{
GetTypeSubtypeString(szCLSID, aInputTypes[i]);
ListInputTypes.AddString(szCLSID);
}
// Show output type/subtype pairs
for (i=0; i<ulNumOutputsSupplied; i++)
{
GetTypeSubtypeString(szCLSID, aOutputTypes[i]);
ListOutputTypes.AddString(szCLSID);
}
}
示例2: OnRecvTCPData
//TCP接收数据处理函数
LONG CTCPServerDlg::OnRecvTCPData(WPARAM wParam,LPARAM lParam)
{
DATA_BUF *pGenBuf = (DATA_BUF*)wParam; //通用缓冲区
CTCPCustom_CE* pTcpCustom= (CTCPCustom_CE* )lParam; //TCP客户端对象
//接收显示列表
CListBox * pLstRecv = (CListBox*)GetDlgItem(IDC_LST_RECV);
ASSERT(pLstRecv != NULL);
//接收到的数据
CString strRecv;
CString strLen;
strLen.Format(L"%d",pGenBuf->dwBufLen);
strRecv = CString(pGenBuf->sBuf);
pLstRecv->AddString(_T("************************************"));
pLstRecv->AddString(_T("来自: ") + CString(pGenBuf->szAddress) );
pLstRecv->AddString(_T("数据长度:")+strLen);
pLstRecv->AddString(strRecv);
//发送回应命令
if (!m_tcpServer.SendData(pTcpCustom,"recv ok",strlen("recv ok")))
{
AfxMessageBox(_T("发送失败"));
}
//释放内存
delete[] pGenBuf->sBuf;
pGenBuf->sBuf = NULL;
delete pGenBuf;
pGenBuf = NULL;
return 0;
}
示例3: EnumDMOsToList
HRESULT EnumDMOsToList(IEnumDMO *pEnumCat, CListBox& ListFilters, int& nFilters)
{
HRESULT hr=S_OK;
ULONG cFetched;
WCHAR *wszName;
CLSID clsid;
// Clear the current filter list
ClearFilterListWithCLSID(ListFilters);
nFilters = 0;
// If there are no filters of a requested type, show default string
if (!pEnumCat)
{
ListFilters.AddString(TEXT("<< No entries >>"));
return S_FALSE;
}
// Enumerate all items associated with the moniker
while(pEnumCat->Next(1, &clsid, &wszName, &cFetched) == S_OK)
{
nFilters++;
CString str(wszName);
// Add filter's name and CLSID to the list box
AddFilterToListWithCLSID(str, &clsid, ListFilters);
CoTaskMemFree(wszName);
}
// If no DMOs matched the query, show a default item
if (nFilters == 0)
ListFilters.AddString(TEXT("<< No entries >>"));
return hr;
}
示例4:
void CBerkeleyView::OnBnClickedButton1()
{
CString csDbFile;
GetDlgItem(IDC_DB_FILE)->GetWindowTextW(csDbFile);
if (!csDbFile.IsEmpty())
{
if (m_spDb.get() != NULL)
{
m_spDb->DestroyDb();
}
m_spDb.reset(new CDbLayer_Test());
m_spDb->InitDb(csDbFile);
CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_DATA_TYPE);
m_spDb->SetDecoder((DataDecoder::DataEncodeType)pBox->GetItemData(pBox->GetCurSel()));
CListBox* pList = (CListBox*)GetDlgItem(IDC_LIST_DB_CONTENT);
pList->ResetContent();
std::vector<tstring> data = m_spDb->GetFirstData();
if (data.size() > 0)
{
tstring line = _T("1 ");
for(int i = 0; i < data.size(); ++i)
{
line.append(data[i].size() > 50 ? data[i].substr(0, 50) + _T("...") : data[i]);
line.append(_T(" "));
}
pList->AddString(line.c_str());
}
int nLine = 1;
data = m_spDb->GetNextData();
while(nLine < 1000 && data.size() > 0)
{
CString csNum;
csNum.Format(_T("%d "), nLine+1);
tstring line = csNum;
for(int i = 0; i < data.size(); ++i)
{
line.append(data[i].size() > 50 ? data[i].substr(0, 50) + _T("...") : data[i]);
line.append(_T(" "));
}
pList->AddString(line.c_str());
data = m_spDb->GetNextData();
++nLine;
}
}
}
示例5: OnInitDialog
BOOL COptDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CListBox *pLB = (CListBox *)GetDlgItem(IDC_LST_BEGIN);
CListBox *pLE = (CListBox *)GetDlgItem(IDC_LST_END);
for(long i = 0 ;i<this->begs.GetSize(); i++)
{
pLB->AddString(begs[i]);
pLE->AddString(ends[i]);
}
CMainFrame *pMain = (CMainFrame*)::AfxGetApp()->GetMainWnd();
CTraDoc *pDoc = (CTraDoc*)pMain->GetActiveDocument();
for (int i = 0; i < _countof(_afxPropSheetButtons); i++)
{
HWND hWndButton = ::GetDlgItem(pDoc->m_pSheet->m_hWnd, _afxPropSheetButtons[i]);
if (hWndButton != NULL && (_afxPropSheetButtons[i] == ID_APPLY_NOW || _afxPropSheetButtons[i] == IDHELP))
{
::ShowWindow(hWndButton, SW_HIDE);
::EnableWindow(hWndButton, FALSE);
}
else if (hWndButton != NULL)
{
CRect btnRt, sheetRt;
::GetWindowRect(hWndButton, &btnRt);
::GetWindowRect(pDoc->m_pSheet->m_hWnd, &sheetRt);
CSize btnSz(100, 25);
pDoc->m_pSheet->ScreenToClient(&btnRt);
pDoc->m_pSheet->ScreenToClient(&sheetRt);
btnSz.cx = (sheetRt.right - sheetRt.left) / 4;
if (_afxPropSheetButtons[i] == IDOK)
{
::MoveWindow(hWndButton, sheetRt.left + (sheetRt.right - sheetRt.left)/8, btnRt.top, btnSz.cx, btnSz.cy, false);
}
else if (_afxPropSheetButtons[i] == IDCANCEL)
{
::MoveWindow(hWndButton, sheetRt.left + (sheetRt.right - sheetRt.left)*5/8, btnRt.top, btnSz.cx, btnSz.cy, false);
}
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例6: AddGraphFiltersToList
HRESULT AddGraphFiltersToList (IGraphBuilder *pGB, CListBox& m_ListFilters)
{
HRESULT hr;
IEnumFilters *pEnum = NULL;
IBaseFilter *pFilter = NULL;
ULONG cFetched;
// Clear filters list box
m_ListFilters.ResetContent();
// Verify graph builder interface
if (!pGB)
return E_NOINTERFACE;
// Get filter enumerator
hr = pGB->EnumFilters(&pEnum);
if (FAILED(hr))
{
m_ListFilters.AddString(TEXT("<ERROR>"));
return hr;
}
// Enumerate all filters in the graph
while(pEnum->Next(1, &pFilter, &cFetched) == S_OK)
{
FILTER_INFO FilterInfo;
TCHAR szName[256];
hr = pFilter->QueryFilterInfo(&FilterInfo);
if (FAILED(hr))
{
m_ListFilters.AddString(TEXT("<ERROR>"));
}
else
{
USES_CONVERSION;
// Add the filter name to the filters listbox
lstrcpy(szName, W2T(FilterInfo.achName));
m_ListFilters.AddString(szName);
// Must release filter graph reference
FilterInfo.pGraph->Release();
}
pFilter->Release();
}
pEnum->Release();
return hr;
}
示例7: OnFileadd
void CProjectView::OnFileadd()
{
// Start in the project directory
((CProjectDoc*)GetDocument())->SetProject();
_TCHAR* FileBuffer = new _TCHAR[4096];
CFileDialog *pfileDlg = NULL;
if (g_osrel >= 4)
{
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
}
else
{
pfileDlg = new CFileDialog(TRUE, NULL, NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
_T("Prolog Files (*.pro;*.plm)|*.pro;*.plm|All (*.*)|*.*||"));
}
pfileDlg->m_ofn.lpstrFile = FileBuffer;
FileBuffer[0] = EOS; // Note, must do this or W95 flags as error
pfileDlg->m_ofn.nMaxFile = 4096;
if (pfileDlg->DoModal() != IDOK)
{
//_TCHAR errbuf[512];
//wsprintf(errbuf, _T("FileDialog error: %d"), CommDlgExtendedError());
//AfxMessageBox(errbuf);
delete pfileDlg;
return;
}
CListBox* pLB = (CListBox*)GetDlgItem(IDP_FILELIST);
// Loop through all the files to be added. If they are in the project
// directory or below, just put in the relative path.
POSITION pos = pfileDlg->GetStartPosition();
CString dir(m_directory), path, upath;
dir.MakeUpper();
int i, idx;
while (pos != NULL)
{
path = pfileDlg->GetNextPathName(pos);
upath = path;
upath.MakeUpper();
if (dir.Right(1) != _T("\\"))
dir = dir + _T("\\");
i = upath.Find(dir);
if (i >= 0)
path = path.Mid(i+dir.GetLength());
idx = pLB->AddString(path);
update_scroll(pLB, path);
}
delete FileBuffer;
delete pfileDlg;
((CProjectDoc*)GetDocument())->SetProject();
}
示例8: OnInitDialog
BOOL CAdministrativePage::OnInitDialog()
{
CNewWizPage::OnInitDialog();
GetDlgItem(IDC_PORTALADMINISTRATIVE_TITLE)->SetFont(&((CPTKInstallerDlg*)GetParent())->m_fontTitle, TRUE);
CWizardData* pWizardData = ((CPTKInstallerDlg*)GetParent())->m_pWizardData;
CListBox* lstLanguages = (CListBox*)GetDlgItem(IDC_PORTAL_LANGUAGES);
//load languages
CString strBuf;
for (int i=0;i < pWizardData->m_arrLanguagesNames.GetSize();i++)
{
strBuf.Format("%s [%s]", pWizardData->m_arrLanguagesNames.ElementAt(i), pWizardData->m_arrLanguagesCodes.ElementAt(i));
lstLanguages->AddString(strBuf);
}
GetDlgItem(IDC_PORTAL_MAILSERVERNAME)->SetWindowText(pWizardData->m_strMailServerName);
strBuf.Format("%d", pWizardData->m_nMailServerPort);
GetDlgItem(IDC_PORTAL_MAILSERVERPORT)->SetWindowText(strBuf);
GetDlgItem(IDC_PORTAL_DEFAULTFROMADDRESS)->SetWindowText(pWizardData->m_strDefaultFromAddress);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例9: fillSuggestionsList
// fillSuggestionsList:
// Fill the suggestions list with suggestions for the current word.
void CSpellingDlg::fillSuggestionsList() {
CWaitCursor busy;
SSCE_CHAR problemWord[SSCE_MAX_WORD_SZ];
GetDlgItemText(IDC_PROBLEMWORD, (TCHAR *)problemWord, sizeof(problemWord));
const int maxSuggestions = 16;
SSCE_CHAR suggestions[maxSuggestions * SSCE_MAX_WORD_SZ];
SSCE_S16 scores[maxSuggestions];
SSCE_Suggest(SSCE_GetSid(), problemWord, suggestionDepth,
suggestions, sizeof(suggestions), scores, maxSuggestions);
CListBox *suggestionsList = (CListBox *)GetDlgItem(IDC_SUGGESTIONSLIST);
suggestionsList->ResetContent();
for (const SSCE_CHAR *p = suggestions; *p != _T('\0');
p += lstrlen((TCHAR *)p) + 1) {
suggestionsList->AddString((TCHAR *)p);
}
// Select the first suggestion and copy it to the Change To field.
if (suggestionsList->GetCount() > 0) {
suggestionsList->SetSel(0);
CString word1;
suggestionsList->GetText(0, word1);
SetDlgItemText(IDC_CHANGETO, word1);
}
}
示例10: OnDeltaposSpinModify
void SettingsDlg::OnDeltaposSpinModify(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
CListBox *listbox;
CListBox *listbox2;
listbox = (CListBox*)GetDlgItem(IDC_AUDIO_CODECS_ALL);
listbox2 = (CListBox*)GetDlgItem(IDC_AUDIO_CODECS);
if (pNMUpDown->iDelta == -1) {
//add
int selected = listbox->GetCurSel();
if (selected != LB_ERR)
{
CString str;
listbox->GetText(selected, str);
listbox2->AddString(str);
listbox->DeleteString(selected);
listbox->SetCurSel( selected < listbox->GetCount() ? selected : selected-1 );
}
} else {
//remove
int selected = listbox2->GetCurSel();
if (selected != LB_ERR)
{
CString str;
listbox2->GetText(selected, str);
listbox->AddString(str);
listbox2->DeleteString(selected);
listbox2->SetCurSel( selected < listbox2->GetCount() ? selected : selected-1 );
}
}
*pResult = 0;
}
示例11: OnEnChangeBrowseOpen
void CFirstFollowDlg::OnEnChangeBrowseOpen()
{
// TODO: 如果该控件是 RICHEDIT 控件,它将不
// 发送此通知,除非重写 CDialogEx::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
CString path;
GetDlgItemText(IDC_BROWSE_OPEN,path);
if(path.GetLength() == 0) return;
SetDlgItemText(IDC_BROWSE_OPEN,_T(""));
this->OnBnClickedButtonClear();
StreamHelper::getStreamFromFileStream( this->productionList, this->orignProductions, path.GetBuffer(0));
CListBox *listBox = (CListBox*) GetDlgItem(IDC_LIST_PROD);
for (size_t i=0;i<this->orignProductions.size();i++)
{
listBox->AddString(this->orignProductions[i].c_str());
}
}
示例12: OnInitDialog
LRESULT PreviewLogDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
GetDlgItem(IDC_PRV_DLG_SERVER_GROUP).SetWindowText(CTSTRING(PRV_DLG_SERVER_GROUP));
GetDlgItem(IDC_PRV_DLG_SERVER_STATE_STATIC).SetWindowText(CTSTRING(PRV_DLG_SERVER_STATE_STATIC));
GetDlgItem(IDC_PRV_DLG_VIDEO_NAME_STATIC).SetWindowText(CTSTRING(PRV_DLG_VIDEO_NAME_STATIC));
GetDlgItem(IDC_PRV_DLG_LOG_GROUP).SetWindowText(CTSTRING(PRV_DLG_LOG_GROUP));
CenterWindow(GetParent());
GetDlgItem(IDCANCEL).SetWindowText(CTSTRING(CLOSE));
SetWindowText(CTSTRING(PREVIEW_LOG_DLG));
UpdateItems();
// Fill IDC_PRV_DLG_LOG_LST
CListBox mBox;
mBox.Attach(GetDlgItem(IDC_PRV_DLG_LOG_LST));
string outString;
while (VideoPreview::getInstance()->GetNextLogItem(outString))
mBox.AddString(Text::toT(outString).c_str());
mBox.Detach();
VideoPreview::getInstance()->SetLogDlgWnd(*this);
return FALSE;
}
示例13: ThreadProc
/*
*函数介绍:线程执行过程
*入口参数:pArg:创建线程时,传进来的参数,这里指的列表框控件指针
*出口参数:(无)
*返回值:这里只返回1。
*/
DWORD CThreadSynBySemaphoreDlg::ThreadProc(PVOID pArg)
{
CListBox* pLstBox = (CListBox*)pArg;
TCHAR buffer[10];
//等待信号量可用,当信号量计数大于0时,可用
if (WaitForSingleObject(g_hSynSemaphore,INFINITE) == WAIT_OBJECT_0)
{
//给数组赋值
for (int i=0;i<MAXDATASIZE;i++)
{
g_incNum++; //加1
g_aGlobalData[i] = g_incNum; //赋值
Sleep(5);
}
//显示已经赋值的数组
for(int i = 0 ; i < MAXDATASIZE ; i++)
{
_itow(g_aGlobalData[i],buffer,10);
pLstBox->AddString(buffer); //
}
}
//因为等待函数自动给信号量计数减1
//所以给信号量计数加1,使信号量继续可用
ReleaseSemaphore(g_hSynSemaphore,1,NULL);
return 1;
}
示例14: Message
bool CNewsHubDlg::Message(const NewsHub::Socket & socket, const unsigned int messageId, const std::string & message)
{
CListBox* pReceivedMessages = (CListBox*)GetDlgItem(IDC_RECEIVED_MESSAGES);
CString str;
if (socket.Type() == "TCP")
{
std::string from, to;
int fromPort, toPort;
NewsHub::TcpSocket* tcpSocket = (NewsHub::TcpSocket*)&socket;
tcpSocket->SockAddr(to, toPort);
tcpSocket->PeerAddr(from, fromPort);
str.Format(_T("(From: %s:%d to: %s:%d msgId:%d): %s"),
CString(from.c_str()), fromPort, CString(to.c_str()), toPort, messageId, CString(message.c_str()));
}
else
{
str.Format(_T("%d: %s"), messageId, CString(message.c_str()));
}
int row = pReceivedMessages->AddString(str);
pReceivedMessages->SetCurSel(row);
CButton* pSendDeliveryConfirmation = (CButton*)GetDlgItem(IDC_SEND_DELIVERY_CONFIRMATION);
return pSendDeliveryConfirmation->GetCheck() == BST_CHECKED;
}
示例15: 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;
}