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(); }
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); } }
CString CProjectDoc::GetLib(int i) { CString sLib; CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_LIBLIST); pLB->GetText(i, sLib); return sLib; }
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; }
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); }
// 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); } }
void CFuncDialog::OnOK() { CListBox* pList = (CListBox*)GetDlgItem(IDC_FUNCLIST); pList->GetText(pList->GetCurSel(), m_current); CDialog::OnOK(); }
/************************************************************************************** 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); } }
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); }
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; }
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; } }
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)); } } } }
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); }
/** * "파일 풀기"를 눌렀을때 파일을 하나 푸는 함수 */ 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; } } } }
// 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); } }
static RString GetCurrentString( const CListBox &list ) { // TODO: Add your control notification handler code here int iSel = list.GetCurSel(); if( iSel == LB_ERR ) return RString(); CString s; list.GetText( list.GetCurSel(), s ); return RString( s ); }
void CSelectDialog::SaveData( CQueryBuilder* builder ) { CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST ); vector<string> fields; for ( int i=0; i<chosenList->GetCount(); i++ ) { CString temp; chosenList->GetText( i, temp ); fields.push_back( (LPCTSTR)temp ); } builder->SetSelect( fields ); }
void CSpellingDlg::OnSuggestionsListSelChange() { // Copy the new selection to the Change To field. CListBox *suggestionsList = (CListBox *)GetDlgItem(IDC_SUGGESTIONSLIST); int i = suggestionsList->GetCurSel(); if (i >= 0) { CString selText; suggestionsList->GetText(i, selText); SetDlgItemText(IDC_CHANGETO, selText); } }
void CDizzyDialog::RecalculateRotation() { CListBox* pListBox = (CListBox*) GetDlgItem(IDC_INPUT_LIST); int num = pListBox->GetCount(); if (num == 0) { CAxisRotation rotResult; char* pszResult = rotResult.ToString(m_iPrecision); m_strResult = pszResult; free(pszResult); } else if (num == 1) { CString strOnly; pListBox->GetText(0,strOnly); CAxisRotation rotResult; rotResult.ParseString(strOnly); rotResult = rotResult.Normalise(); char* pszResult = rotResult.ToString(m_iPrecision); m_strResult = pszResult; free(pszResult); } else { if (num > 1) { CString strFirst; pListBox->GetText(0, strFirst); CAxisRotation rotFirst; rotFirst.ParseString(strFirst); CQuaternion quatResult(rotFirst); for (int i=1; i<num; i++) { CString strData; pListBox->GetText(i, strData); CAxisRotation rotData; rotData.ParseString(strData); CQuaternion quatData(rotData); quatResult = quatData * quatResult; } CAxisRotation rotResult(quatResult); char* pszResult = rotResult.ToString(m_iPrecision); m_strResult = pszResult; free(pszResult); } } }
void CFuncDialog::OnSelchangeFunclist() { CHawkApp* app = (CHawkApp*)AfxGetApp(); CStatic* tip = (CStatic*)GetDlgItem(IDC_FUNCTIP); CListBox* pList = (CListBox*)GetDlgItem(IDC_FUNCLIST); CString current; pList->GetText(pList->GetCurSel(), current); current = app->GenDecl(current); tip->SetWindowText(current); }
void CChannelSelectDlg::OnSelchangeChannellist() { // TODO: Add your control notification handler code here CListBox *pListBox = (CListBox *)GetDlgItem( IDC_CHANNELLIST ); CString str; int iCurSel; iCurSel = pListBox->GetCurSel(); pListBox->GetText( iCurSel, str ); GetDlgItem( IDC_SELLECTEDCHANNEL )->SetWindowText( str ); }
void CSelectDialog::OnRemoveButtonClicked() { CListBox* fieldList = (CListBox*)GetDlgItem( IDC_FIELDLIST ); CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST ); for ( int i=chosenList->GetCount()-1; i>=0; i-- ) { if ( chosenList->GetSel( i ) ) { CString temp; chosenList->GetText( i, temp ); fieldList->AddString( temp ); chosenList->DeleteString( i ); } } }
void CUserListDlg::OnUserListDblClk() { CString username; CUserEditDlg dialog; CListBox* userList = (CListBox*)GetDlgItem( IDC_USERLIST ); if ( userList ) { if ( userList->GetCurSel() >= 0 ) { userList->GetText( userList->GetCurSel(), username ); dialog.DoModal( (LPCTSTR)username ); RefreshUserList(); } } }
static void SelectString( CListBox &list, const RString &sToSelect ) { for( int i=0; i<list.GetCount(); i++ ) { CString s; list.GetText( i, s ); if( s == sToSelect ) { list.SetCurSel( i ); break; } } }
static inline void ApplyRegexTexts(vector<RegexText>& vec, CListBox& list) { int size = list.GetCount(); vec.resize(size); CString tmp; for (int i = 0; i < size; i++) { list.GetText(i, tmp); vec[i].isRegex = tmp.Left(REGEX_PREFIX_LENGTH) == IS_REGEX_PREFIX; vec[i].text = tmp.Right(tmp.GetLength() - REGEX_PREFIX_LENGTH); vec[i].regexp = vec[i].isRegex ? vec[i].text : _T(""); } }
CString CProjectDoc::GetFile(int i) { CString sFile; // Consider file -1 a special case for getting the opdefs file if (i == -1) sFile = GetProjectView()->m_opdefs; else { CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_FILELIST); pLB->GetText(i, sFile); } return sFile; }
void CGroupAddDialog::BuildAndRemoveSelected(CListBox& lb, std::vector<std::string>& str) { str.clear(); int selcnt = lb.GetSelCount(); if (selcnt) { int *sels = new int[selcnt]; lb.GetSelItems(selcnt, sels); for(int x=selcnt -1; x >= 0; --x) { str.push_back(lb.GetText(sels[x])); lb.DeleteString(sels[x]); } } }
void CSelectDialog::OnDownButtonClicked() { CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST ); for ( int i=chosenList->GetCount()-2; i>=0; i-- ) { if ( chosenList->GetSel( i ) ) { if ( !chosenList->GetSel( i+1 ) ) { char temp[4000]; chosenList->GetText( i+1, temp ); chosenList->InsertString( i, temp ); chosenList->SetSel( i+2, TRUE ); chosenList->DeleteString( i+2 ); } } } }
void CSelectDialog::OnUpButtonClicked() { CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST ); for ( int i=1; i<chosenList->GetCount(); i++ ) { if ( chosenList->GetSel( i ) ) { char temp[4000]; if ( !chosenList->GetSel( i-1 ) ) { chosenList->GetText( i, temp ); chosenList->InsertString( i-1, temp ); chosenList->SetSel( i-1, TRUE ); chosenList->DeleteString( i+1 ); } } } }
void CSoundAnimDlg::OnRemoveSound() { if (_SelectedMarker != 0) { char s[256]; CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST); if (list->GetText(list->GetCurSel(), s) != LB_ERR) { string name(s); _SelectedMarker->removeSound(CStringMapper::map(name)); updateSounds(); } } }