int FindReplDlg::GetFindText(CComboBox& wnd, bsString& text) { int len; char *tp; int sel = wnd.GetCurSel(); if (sel == -1) { len = wnd.GetWindowTextLength()+1; tp = new char[len]; wnd.GetWindowText(tp, len); sel = wnd.FindStringExact(-1, tp); if (sel == -1) { sel = wnd.InsertString(0, tp); wnd.SetCurSel(sel); } int cnt; while ((cnt = wnd.GetCount()) >= 20) wnd.DeleteString(cnt-1); } else { len = wnd.GetLBTextLen(sel)+1; tp = new char[len]; wnd.GetLBText(sel, tp); } text.Attach(tp); return sel; }
//=========================================================================== void CFAVConnectDlg::OnBnClickedConnectCheck() //=========================================================================== { // TODO: Add your control notification handler code here CArray<CString,CString> strArrayCOM; UINT uPortCount; CComboBox* pCbox = (CComboBox*)GetDlgItem(IDC_CONNECT_COMSEL); CString strCOMPORT; if(m_bCOMSel){ GetDlgItem(IDC_CONNECT_COMSEL)->EnableWindow(FALSE); m_bGetSerialPort = FALSE; for(UINT i = pCbox->GetCount(); i > 0; i--){ pCbox->DeleteString(i-1); } m_bCOMSel = FALSE; } else{ if(!m_bGetSerialPort){ m_bGetSerialPort = TRUE; uPortCount = m_UARTComm.GetSerialPort(TRUE, strArrayCOM); for(UINT i = 0; i < uPortCount; i++){ strCOMPORT = strArrayCOM.GetAt(m_UARTComm.GetCOMIndex(i)); pCbox->InsertString(i,strCOMPORT); } pCbox->SetCurSel(0); } GetDlgItem(IDC_CONNECT_COMSEL)->EnableWindow(TRUE); m_bCOMSel = TRUE; } }
long CCompileEditView::DeleteCurExp(WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/) { HSTreeToCompileEdit* pppData = (HSTreeToCompileEdit*)lParam; if(pppData == NULL) return 0; CTreeGroup* pTreeGroup = (CTreeGroup*)pppData->m_pName; if(pTreeGroup != NULL) { CExpression* pExpress = pTreeGroup->GetData(); if(pExpress != NULL) { CString strName; strName.Format("%s",pExpress->GetName()); CValue* pValoare; if ( m_pExternExpression->Lookup(strName,pExpress->GetExpressType(),pValoare) ) { if( !pExpress->GetPWD().IsEmpty() ) // 有密码 { CInputPassPwD dlg(this,_T("请输入公式密码"),strName); dlg.m_pExp = pExpress; if( dlg.DoModal() == IDCANCEL ) { return 2; } } if( wParam ) { m_pExternExpression->RemoveKey(strName,pExpress->GetExpressType()); delete pValoare; } } if(m_pwndDlgMainBar != NULL) { CComboBox* pCombox = (CComboBox*)m_pwndDlgMainBar->GetDlgItem(IDC_NAMECOMBO); if(pCombox != NULL) { int nIndex = pCombox->FindString( 0, strName ); if(nIndex != -1) { pCombox->DeleteString( nIndex ); } } } } } else { } if(m_hExpressInTreePos == (HTREEITEM)pppData->m_pData) { OnNewExpress(); } return 0; }
void CComboBox_Clear(CComboBox &ctrlComboBox) { ASSERT(ctrlComboBox.GetSafeHwnd() != NULL); if (ctrlComboBox.GetSafeHwnd() == NULL) return; for (int i = ctrlComboBox.GetCount() - 1; i >= 0; i--) ctrlComboBox.DeleteString(i); }
void ClearComboBox(CComboBox &stComboBox) { stComboBox.Clear(); { int n = stComboBox.GetCount(); for (int i=0; i<n; i++) { stComboBox.DeleteString(0); } } }
BOOL CFcFontBar::AddHtmlTag(const CString& tag, BOOL bClear) { CComboBox* pCb = (CComboBox*)GetDlgItem(ID_FORMAT_BLOCKFORMAT); ASSERT_VALID(pCb); if (bClear) { for (int ii = pCb->GetCount()-1; ii >= 0; ii--) pCb->DeleteString(ii); } pCb->AddString(tag); return TRUE; }
void NewGUI_ComboBox_UpdateHistory(CComboBox& comboBox, const std::basic_string<TCHAR>& strNew, std::vector<std::basic_string<TCHAR> >* pvHistoryItems, size_t dwMaxHistoryItems) { ASSERT(pvHistoryItems != NULL); if(pvHistoryItems == NULL) return; if(strNew.size() > 0) { std::vector<std::basic_string<TCHAR> >::iterator itExists = std::find(pvHistoryItems->begin(), pvHistoryItems->end(), strNew); if(itExists != pvHistoryItems->end()) pvHistoryItems->erase(itExists); size_t dwCurSize = pvHistoryItems->size(); ASSERT(dwCurSize <= dwMaxHistoryItems); while(dwCurSize >= dwMaxHistoryItems) { pvHistoryItems->erase(pvHistoryItems->begin()); if(dwCurSize == pvHistoryItems->size()) { ASSERT(FALSE); break; } dwCurSize = pvHistoryItems->size(); } pvHistoryItems->push_back(strNew); } ASSERT(pvHistoryItems->size() <= dwMaxHistoryItems); const int nOrgCount = comboBox.GetCount(); for(int n = 0; n < nOrgCount; ++n) { const UINT uIndex = static_cast<UINT>(nOrgCount - n - 1); VERIFY(comboBox.DeleteString(uIndex) != CB_ERR); } for(size_t i = 0; i < pvHistoryItems->size(); ++i) { const size_t iIndex = pvHistoryItems->size() - i - 1; comboBox.AddString(pvHistoryItems->at(iIndex).c_str()); } if(comboBox.GetCount() > 0) { comboBox.AddString(HCMBX_SEPARATOR); comboBox.AddString(HCMBX_CLEARLIST); } }
//================================================= // Message Handlers //================================================= void CMainDlg::OnDestroy() { CDialog::OnDestroy(); GetControlValues(); // Clean up CLSIDs in combobox CComboBox* pCombo = NULL; VERIFY(pCombo = (CComboBox*)GetDlgItem(IDC_IMAGE_EXT)); while(pCombo->GetCount() > 0) { CLSID* pCLSID = (CLSID*)pCombo->GetItemData(0); delete pCLSID; pCombo->DeleteString(0); } }
void CNetworkControllView::AddNewTimeServer(const CString& strTimeServer) { BOOL bFind = FALSE; UINT i =0; for (i = 0; i < m_szServers.size(); i++) { if (strTimeServer.CompareNoCase(m_szServers[i]) == 0) { bFind = TRUE; } } if (!bFind) // new time server { CComboBox* pCbx = (CComboBox*)GetDlgItem(IDC_COMBO_TIMESERVERLIST); if(m_szServers.size() >= 10) { for (UINT j =5; j < 9; j++) { m_szServers[j] = m_szServers[j+1]; } m_szServers[9]=strTimeServer; pCbx->DeleteString(5); } else { m_szServers.push_back(strTimeServer); } // // write to register for (UINT i = 5; i < m_szServers.size(); i++) { CString strIndex; int nsize = m_szServers.size(); strIndex.Format(_T("server%d"), i+1); SaveTimeServerToRegister(m_szServers[i], strIndex); } pCbx->AddString(strTimeServer); } }
BOOL CMiscDlg::OnInitDialog () { CDialog::OnInitDialog (); ((CSpinButtonCtrl*)GetDlgItem(IDC_spinMaxStations))->SetRange(_MAX_STATIONS, _MIN_STATIONS); //Country codes CComboBox *pcbCountry = (CComboBox*)GetDlgItem (IDC_cbCountry); while (pcbCountry->GetCount ()) pcbCountry->DeleteString (0); for (int i = 0; i < g_nMaxCountryCode; i++) pcbCountry->AddString(g_stCountryCodeTable[i].szName); if ( ! m_pConfig->GetCountryCode()) _LogTrace (_T("GetCountryCode failed")); EnableControls (FALSE); return TRUE; // return TRUE unless you set the focus to a control }
void CMy3rdDlg::GetHeroName() { size_t ix = 0; CComboBox *pCtrl = (CComboBox *)GetDlgItem(HeroNames); for(ix = 0;;++ix) { char *HeroName=new char[0x0D]; ReadProcessMemory(hProcess,LPVOID(NameAdd + 0x492 * ix),HeroName,0x0D,NULL); if(*HeroName == 0) { delete []HeroName; if(ix == 0) return; else { pCtrl->DeleteString(ix - 1); break; } } pCtrl->AddString(_T(HeroName)); ++HeroNum; delete []HeroName; } AddedName = 1; }
BOOL CDynToolBar::PreTranslateMessage(MSG* pMsg) {// Handle a few messages for our children... CWnd* pWnd = FromHandle(pMsg->hwnd); //Get a temp CWnd object for the message we're processing. //if (pMsg->message!=WM_PAINT) // { // sprintf(buff, "H=%08x ", (DWORD)(pWnd->m_hWnd)); // dbgWM_Msg(buff, pMsg->message, pMsg->wParam, pMsg->lParam, 1); // } if (IsChild(pWnd)) {//It's a child of ours... CWnd* pParent = pWnd->GetParent(); if (pParent && pParent->IsKindOf(RUNTIME_CLASS(CComboBox))) {//The parent is a ComboBox! switch (pMsg->message) { case WM_KEYDOWN: if (pMsg->wParam==VK_RETURN) { int Index = FindComboButtonIndex(pParent); if (Index>=0) { int IDIndex = FindComboButtonIDIndex(Index); if (IDIndex>=0) { CComboBox* pCBox = (CComboBox*)pParent; int nIndex = pCBox->GetCurSel(); if (nIndex==CB_ERR) { pCBox->GetWindowText(sCurSel); if (sCurSel.GetLength()>0 && pCBox->FindStringExact(-1, (const char*)sCurSel)==CB_ERR) { bComboListChanged = 1; pCBox->InsertString(0, (const char*)sCurSel); pCBox->SetCurSel(0); } } else { pCBox->GetLBText(nIndex, sCurSel); if (nIndex>0) { bComboListChanged = 1; pCBox->DeleteString(nIndex); pCBox->InsertString(0, (const char*)sCurSel); pCBox->SetCurSel(0); } } ScdMainWnd()->PostMessage(WM_COMMAND, BtnIDs[IDIndex]); } } } else if (bUseEscape && pMsg->wParam==VK_ESCAPE) { ScdMainWnd()->PostMessage(WM_COMMAND, ID_GRF_Esc); } break; }//end switch } else if (pParent && pParent->IsKindOf(RUNTIME_CLASS(CEdit))) {//The parent is a CEdit! switch (pMsg->message) { case WM_KEYDOWN: if (pMsg->wParam==VK_RETURN) { ScdMainWnd()->PostMessage(WM_COMMAND, ID_GRF_Done); } else if (bUseEscape && pMsg->wParam==VK_ESCAPE) { ScdMainWnd()->PostMessage(WM_COMMAND, ID_GRF_Esc); } break; }//end switch } } return CToolBar::PreTranslateMessage(pMsg); }