本文整理汇总了C++中CListBox::GetText方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::GetText方法的具体用法?C++ CListBox::GetText怎么用?C++ CListBox::GetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CListBox
的用法示例。
在下文中一共展示了CListBox::GetText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnOK
void xSceneOpenDlg::OnOK()
{
CString strFloder, strSceneName;
CListBox * listFloder = (CListBox *)GetDlgItem(IDC_SceneOpen_Floder);
CListBox * listScene = (CListBox *)GetDlgItem(IDC_SceneOpen_Scene);
int isel = listScene->GetCurSel();
if (isel < 0)
{
MessageBox("Please select scene!", "Error", MB_OK);
return ;
}
listScene->GetText(isel, strSceneName);
if (strSceneName == "")
{
MessageBox("Please select scene!", "Error", MB_OK);
return ;
}
isel = listFloder->GetCurSel();
listFloder->GetText(isel, strFloder);
d_assert (isel >= 0);
xScene::Instance()->Load((LPCTSTR)strSceneName, (LPCTSTR)strFloder);
CDialog::OnOK();
}
示例2: Serialize
void CProjectDoc::Serialize(CArchive& ar)
{
CProjectView* pview = GetProjectView();
int i, l;
if (ar.IsStoring())
{ // Output
#ifdef _UNICODE
_TCHAR uniflag = 0xfeff; // written as fffe, which is right for PC unicode
ar.Write(&uniflag, 2);
#endif
pview->UpdateData(TRUE);
ar.WriteString(_T("amzirel=4")); // so we can check for valid ppj files
ar.WriteString(CRLF);
ar.WriteString(_T("xplfile="));
ar.WriteString(pview->m_xplfile);
ar.WriteString(CRLF);
ar.WriteString(_T("directory="));
ar.WriteString(pview->m_directory);
ar.WriteString(CRLF);
ar.WriteString(_T("opdefs="));
ar.WriteString(pview->m_opdefs);
ar.WriteString(CRLF);
CListBox* pLB;
CString s;
pLB = (CListBox*)(pview->GetDlgItem(IDP_FILELIST));
l = pLB->GetCount();
for (i=0; i<l; i++)
{
pLB->GetText(i, s);
ar.WriteString(_T("file="));
ar.WriteString(s);
ar.WriteString(CRLF);
}
pLB = (CListBox*)(pview->GetDlgItem(IDP_LIBLIST));
l = pLB->GetCount();
for (i=0; i<l; i++)
{
pLB->GetText(i, s);
ar.WriteString(_T("library="));
ar.WriteString(s);
ar.WriteString(CRLF);
}
SaveOpenFiles(ar);
}
else
{ // Input
ReadArchive(ar);
}
}
示例3: GetLib
CString CProjectDoc::GetLib(int i)
{
CString sLib;
CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_LIBLIST);
pLB->GetText(i, sLib);
return sLib;
}
示例4: 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;
}
示例5: SetWidthByContentInListBox
void SetWidthByContentInListBox(CDialog* pDlg, int nID)
{
if (nID <= 0|| pDlg == NULL) return;
CWnd* pWnd = (CWnd*)pDlg;
CListBox* pCB = (CListBox*)pWnd->GetDlgItem(nID);
if (pCB == NULL) return;
int origSize = pCB->GetHorizontalExtent();
int maxSize = origSize;
CDC* pDC = pWnd->GetDC();
CString cStr;
int str_num = pCB->GetCount();
for (int i = 0; i < str_num; i++)
{
pCB->GetText(i, cStr);
CSize strSize = pDC->GetOutputTextExtent(cStr);
if (strSize.cx > maxSize)
maxSize = strSize.cx;
}
// in case when adding to list, existing items may be
// longer than newer ones, so may not want to resize
if (maxSize > origSize)
pCB->SetHorizontalExtent(maxSize);
}
示例6: 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);
}
}
示例7: OnOK
void CFuncDialog::OnOK()
{
CListBox* pList = (CListBox*)GetDlgItem(IDC_FUNCLIST);
pList->GetText(pList->GetCurSel(), m_current);
CDialog::OnOK();
}
示例8: SetHorizExtentListBox
/**************************************************************************************
Function Name : SetHorizExtentListBox
Input(s) : CListBox& omListBox
Output : void
Functionality : Sets the Listbox scroll to an extent so as to view the longest
string that is inserted.
Member of : CExploreMsgSg
Author(s) : Robin G.K.
Date Created : 27.10.2015
Requirement ID : RS_FLX_08_09_10
***************************************************************************************/
void CExploreMsgSg::SetHorizExtentListBox(CListBox& omListBox)
{
// Set horizontal extent of the list
// box to max string availaable
// so that user can scroll
CSize sz;
CString omStrText;
CDC* pDC = omListBox.GetDC();
if ( pDC != nullptr)
{
int nDx = 0;
for (int nCount = 0;
nCount < omListBox.GetCount();
nCount++)
{
omListBox.GetText( nCount, omStrText );
// remove space
omStrText.TrimRight();
sz = pDC->GetTextExtent(omStrText);
if (sz.cx > nDx)
{
nDx = sz.cx;
}
}
omListBox.ReleaseDC(pDC);
// Set the horizontal extent so every character of all
// strings can be scrolled to.
omListBox.SetHorizontalExtent(nDx);
}
}
示例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: 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: OnFloderChanged
void xSceneOpenDlg::OnFloderChanged()
{
CListBox * listFloder = (CListBox *)GetDlgItem(IDC_SceneOpen_Floder);
CListBox * listScene = (CListBox *)GetDlgItem(IDC_SceneOpen_Scene);
while (listScene->GetCount())
listScene->DeleteString(0);
int isel = listFloder->GetCurSel();
if (isel < 0)
return ;
CString strFloder;
listFloder->GetText(isel, strFloder);
ResourceGroup * rg = ResourceManager::Instance()->GetResourceGroup();
Archive * ar = rg->GetArchive((LPCTSTR)strFloder);
Archive::FileInfoVisitor v = ar->GetFileInfos();
while (!v.eof())
{
const TString128 & filename = v.Cursor()->second.name;
if (File::GetExternName(filename) == "scene")
{
listScene->AddString(filename.c_str());
}
++v;
}
}
示例12: 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));
}
}
}
}
示例13: OnDblclkFilelist
void CProjectView::OnDblclkFilelist()
// Open the file in the editor when double clicked
{
CListBox* pLB = (CListBox*)GetDlgItem(IDP_FILELIST);
int i = pLB->GetCurSel();
CString sFile;
pLB->GetText(i, sFile);
theApp.WOpen(sFile);
}
示例14: OnMenu_Extract
/**
* "파일 풀기"를 눌렀을때 파일을 하나 푸는 함수
*/
void CFV_Select::OnMenu_Extract ()
{
int * pIndecies = NULL; /// 선택된 인덱스를 저장
CListBox * plistSel = NULL; /// 리스트 박스용
int nSelCnt = 0; /// 선택된 갯수
BYTE * btBuff = NULL; /// 임시버퍼
CVFS_Manager * pVFS = NULL; /// vfs파일 핸들
FILE * fp = NULL; /// 임시 파일포인터
VFileHandle *pVFH = NULL; /// vfs 파일핸들
CString strText = "", strFileName = "", strDir = ""; /// 스트링, 파일이름, 폴더
if(m_list.GetSelCount () > 0 && (plistSel = GetListBox ()) && (pVFS = ::g_pDlg_Main->GetVFS())
&&::g_pDlg_Main->GetSelectedVfsName ().GetLength () > 0)
{
/// 파일을 풀 디렉토리를 묻는다
if(GetFolder (&strDir, "파일을 풀 폴더를 선택하세요", GetSafeHwnd (), NULL, NULL))
{
/// 인덱스를 저장하기 위해서 메모리를 할당
if((pIndecies = new int[m_list.GetSelCount ()]))
{
/// 선택된 인덱스들을 가져옴
m_list.GetSelItems (m_list.GetSelCount (), pIndecies);
nSelCnt = m_list.GetSelCount ();
for(short i = 0; i < nSelCnt; i++)
{
strText = "";
/// 리스트박스에서 문자열을 가져옴
plistSel->GetText (pIndecies[ nSelCnt - 1 - i ], strText);
/// base file명만 불리해서 여기에 다시 저장하고 그리고 파일 생성할 때 사용한다
strFileName = strText;
if(strFileName.ReverseFind ('\\') >= 0)
{
strFileName = strFileName.Right (strFileName.GetLength () - strFileName.ReverseFind ('\\') - 1);
}
long lFileLength = pVFS->GetFileLength (strText.GetString ());
if(lFileLength >= 0 && (btBuff = new BYTE[ lFileLength ]))
{
if((pVFH = pVFS->OpenFile (strText.GetString ())))
{
vfread (btBuff, sizeof (BYTE), (size_t)lFileLength, pVFH);
_fmode = _O_BINARY;
if((fp = fopen (strDir + "\\" + strFileName, "w")))
{
fwrite (btBuff, sizeof(BYTE), (size_t)lFileLength, fp);
fclose (fp);
}
delete btBuff;
pVFS->CloseFile (pVFH);
}
}
}
delete pIndecies;
}
}
}
}
示例15: OnDblclkMessageList
// Cycles among sexp nodes with message text
void event_editor::OnDblclkMessageList()
{
CListBox *list = (CListBox*) GetDlgItem(IDC_MESSAGE_LIST);
int num_messages;
int message_nodes[MAX_SEARCH_MESSAGE_DEPTH];
// get current message index and message name
int cur_index = list->GetCurSel();
// check if message name is in event tree
char buffer[256];
list->GetText(cur_index, buffer);
num_messages = m_event_tree.find_text(buffer, message_nodes);
if (num_messages == 0) {
char message[256];
sprintf(message, "No events using message '%s'", buffer);
MessageBox(message);
} else {
// find last message_node
if (m_last_message_node == -1) {
m_last_message_node = message_nodes[0];
} else {
if (num_messages == 1) {
// only 1 message
m_last_message_node = message_nodes[0];
} else {
// find which message and go to next message
int found_pos = -1;
for (int i=0; i<num_messages; i++) {
if (message_nodes[i] == m_last_message_node) {
found_pos = i;
break;
}
}
if (found_pos == -1) {
// no previous message
m_last_message_node = message_nodes[0];
} else if (found_pos == num_messages-1) {
// cycle back to start
m_last_message_node = message_nodes[0];
} else {
// go to next
m_last_message_node = message_nodes[found_pos+1];
}
}
}
// highlight next
m_event_tree.hilite_item(m_last_message_node);
}
}