本文整理汇总了C++中CListBox类的典型用法代码示例。如果您正苦于以下问题:C++ CListBox类的具体用法?C++ CListBox怎么用?C++ CListBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CListBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: PlayMenuMovie
static void PlayMenuMovie (void)
{
int h, i, j;
CStack<char*> m;
char* ps;
CListBox lb;
i = movieManager.m_nLibs;
for (h = j = 0; j < i; j++)
if (j != 2) //skip robot movies
h += movieManager.m_libs [j].m_nMovies;
if (!h)
return;
if (!m.Create (h))
return;
for (i = j = 0; i < h; i++)
if ((ps = movieManager.Cycle (i == 0, 0))) {
if (j && !strcmp (ps, m [0]))
break;
m.Push (ps);
}
i = lb.ListBox (TXT_SELECT_MOVIE, m);
if (i > -1) {
SDL_ShowCursor (0);
if (strstr (m [i], "intro"))
subTitles.Init ("intro.tex");
else if (strstr (m [i], ENDMOVIE))
subTitles.Init (ENDMOVIE ".tex");
movieManager.Play (m [i], 1, 1, gameOpts->movies.bResize);
subTitles.Close ();
SDL_ShowCursor (1);
}
songManager.PlayCurrent (1);
}
示例3: GetDlgItem
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;
}
示例4: AlignListBoxWithCombo
void CTTComboBox::AlignListBoxWithCombo()
{
if (m_cbi.hwndList == NULL ||
!::IsWindow(m_cbi.hwndList))
return;
CListBox* pList = (CListBox*)CWnd::FromHandle(m_cbi.hwndList);
CRect l_rcCombo;
GetClientRect(&l_rcCombo);
CRect l_rcList;
pList->GetClientRect(&l_rcList);
int dropWidth = GetDroppedWidth();
int listWidth = l_rcList.Width();
int xOffset = 0;
switch (m_alignStyle)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = dropWidth - l_rcCombo.Width();
break;
case 2:
xOffset = (dropWidth - l_rcCombo.Width()) / 2;
break;
default:
xOffset = 0;
break;
}
pList->ClientToScreen(&l_rcList);
pList->SetWindowPos(NULL, l_rcList.left - xOffset, l_rcList.top, 0, 0, SWP_NOSIZE);
}
示例5: 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;
}
示例6: atoi
void CNewsHubDlg::OnBnClickedServerStart()
{
CEdit* pPort = (CEdit*)GetDlgItem(IDC_SERVER_PORT);
CString strPort;
pPort->GetWindowText(strPort);
int port = atoi(CT2CA(strPort));
CButton* pServerTcp = (CButton*)GetDlgItem(IDC_SERVER_TCP);
bool bTcp = (pServerTcp->GetCheck() == BST_CHECKED);
ServerLoop* serverLoop;
try
{
NewsHub::Server* server;
if (bTcp)
server = new NewsHub::TcpServer(port);
else
server = new NewsHub::UdpServer(port);
serverLoop = new ServerLoop(server, new NewsHub::ServerThreadLoop(*server, *this, bTcp));
}
catch (std::exception & e)
{
MessageBox(CString(e.what()), _T("Exception"), MB_OK);
return;
}
CString serverDescription = CString(bTcp?"TCP":"UDP") + CString(" server is listening on port ") + strPort;
CListBox* pRunningServers = (CListBox*)GetDlgItem(IDC_RUNNING_SERVERS);
int row = pRunningServers->AddString(serverDescription);
pRunningServers->SetItemDataPtr(row, serverLoop);
}
示例7: GetDlgItem
void AnimDialog::LoadAnimList()
{
CListBox *pAnimList = static_cast< CListBox* >( GetDlgItem( IDC_LIST_ANIM ) );
ClearAnimList();
ModelBase *pMB = m_pDM->GetMesh();
AnimatableBase *pMesh = dynamic_cast< AnimatableBase* >( pMB );
if ( pMesh != NULL )
{
int animNum = pMesh->GetAnimNum();
for ( int i = 0; i < animNum; i ++ )
{
CSMAnimation anim = pMesh->GetAnimInfo( i );
pAnimList->AddString( anim.animName.c_str() );
}
if ( animNum == 0 )
{
EnableAnimControls( FALSE );
}
else
{
EnableAnimControls( TRUE );
pAnimList->SetCurSel( 0 );
}
}
}
示例8: getListBox
void CChangeOrderDlg::removeSelected(const CompactIntArray &selected) {
CListBox *lb = getListBox();
for(intptr_t i = selected.size() - 1; i >= 0; i--) {
m_editList.removeIndex(selected[i]);
lb->DeleteString(selected[i]);
}
}
示例9: AdjustHorzScroll
void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
{
CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);
int cxExtentMax = 0;
for (int i = 0; i < wndListBox.GetCount(); i ++)
{
CString strItem;
wndListBox.GetText(i, strItem);
//cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx);
// Just Ignore the min/max macro stuff
if (cxExtentMax >= dc.GetTextExtent(strItem).cx)
{
cxExtentMax = cxExtentMax;
}
else
{
cxExtentMax = dc.GetTextExtent(strItem).cx;
}
}
wndListBox.SetHorizontalExtent(cxExtentMax);
dc.SelectObject(pOldFont);
}
示例10: getWindowText
BOOL CExpressionTreeDlg::OnInitDialog() {
__super::OnInitDialog();
m_treeCtrl.substituteControl(this, IDC_TREE_EXPRESSION);
m_layoutManager.OnInitDialog(this);
m_layoutManager.addControl(IDC_TREE_EXPRESSION , RELATIVE_SIZE );
m_layoutManager.addControl(IDCLOSE , RELATIVE_X_POS);
m_layoutManager.addControl(IDC_CHECKEXTENDEDINFO, RELATIVE_X_POS);
m_layoutManager.addControl(IDC_LIST_SYMBOLTABLE , RELATIVE_Y_POS | RELATIVE_WIDTH);
m_treeCtrl.showTree(m_node, m_extendedInfo);
const String treeFormName = m_expr.getTreeFormName();
const String stateName = m_expr.getStateName();
const int nodeCount = m_expr.getNodeCount();
String title = getWindowText(this);
title += format(_T(" - %s form - state %s. %d nodes")
,treeFormName.cstr()
,stateName.cstr()
,nodeCount
);
setWindowText(this, title);
CListBox *lb = (CListBox*)GetDlgItem(IDC_LIST_SYMBOLTABLE);
const ExpressionVariableArray variables = m_expr.getSymbolTable().getAllVariables();
for(size_t i = 0; i < variables.size(); i++) {
const ExpressionVariableWithValue &v = variables[i];
lb->InsertString(-1, v.toString().cstr());
}
return TRUE;
}
示例11: 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);
}
}
示例12: 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;
}
示例13: GetDlgItemText
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());
}
}
示例14: OnOK
void CFuncDialog::OnOK()
{
CListBox* pList = (CListBox*)GetDlgItem(IDC_FUNCLIST);
pList->GetText(pList->GetCurSel(), m_current);
CDialog::OnOK();
}
示例15: OnSelchangeSuggestions
void CSpellingDialog::OnSelchangeSuggestions()
{
// Stick the selected word in the "change to" edit.
CListBox* pList = (CListBox*)GetDlgItem(IDC_SUGGESTIONS);
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_CHANGE_TO);
CString csText;
if (pEdit != NULL)
{
if (pList != NULL)
{
TRY
{
int nCurSel = pList->GetCurSel();
if (nCurSel >= 0)
{
pList->GetText(nCurSel, csText);
}
}
END_TRY
}
// Set the text.
BOOL fInnerSet = m_fInnerSet;
m_fInnerSet = TRUE;
pEdit->SetWindowText(csText);
m_fInnerSet = fInnerSet;
}