LRESULT SpeedPage::onSpeedChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { tstring speed; speed.resize(1024); speed.resize(GetDlgItemText(wID, &speed[0], 1024)); if (!speed.empty() && wNotifyCode != CBN_SELENDOK) { boost::wregex reg; if(speed[speed.size() -1] == '.') reg.assign(_T("(\\d+\\.)")); else reg.assign(_T("(\\d+(\\.\\d+)?)")); if (!regex_match(speed, reg)) { CComboBox tmp; tmp.Attach(hWndCtl); DWORD dwSel; if ((dwSel = tmp.GetEditSel()) != CB_ERR) { tstring::iterator it = speed.begin() + HIWORD(dwSel)-1; speed.erase(it); tmp.SetEditSel(0,-1); tmp.SetWindowText(speed.c_str()); tmp.SetEditSel(HIWORD(dwSel)-1, HIWORD(dwSel)-1); tmp.Detach(); } } } updateValues(wNotifyCode); validateMCNLimits(wNotifyCode); return TRUE; }
void CFileFindDlg::OnRegexBtn() { CComboBox* pFindCbo = (CComboBox*)GetDlgItem(IDC_FINDTXT_CBO); DWORD dwSel = pFindCbo->GetEditSel(); CWnd* pRegexBtn = GetDlgItem(IDC_REGEX_BTN); if (pRegexBtn) { CRect r; pRegexBtn->GetWindowRect(&r); CMenu menu; if (menu.LoadMenu(IDR_FINDPOPUP)) { CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, r.left, r.top, this); } } }