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;
}
Beispiel #2
0
void SpeedPage::write() {

	PropPage::write((HWND)(*this), items);

	if (!SETTING(DL_AUTODETECT)) {
		PropPage::write((HWND)(*this), downloadItems);
	}

	if (!SETTING(UL_AUTODETECT)) {
		PropPage::write((HWND)(*this), uploadItems);

		if(SETTING(SLOTS) < 1)
			settings->set(SettingsManager::SLOTS, 1);

		if(SETTING(EXTRA_SLOTS) < 1)
			settings->set(SettingsManager::EXTRA_SLOTS, 1);

		if(SETTING(SET_MINISLOT_SIZE) < 64)
			settings->set(SettingsManager::SET_MINISLOT_SIZE, 64);
	}

	if (!SETTING(MCN_AUTODETECT)) {
		validateMCNLimits(0);
		PropPage::write((HWND)(*this), mcnItems);

		/*if(SETTING(MAX_MCN_DOWNLOADS) < 1)
			settings->set(SettingsManager::MAX_MCN_DOWNLOADS, AirUtil::getSlotsPerUser(true, Util::toDouble(SETTING(DOWNLOAD_SPEED))));

		if(SETTING(MAX_MCN_UPLOADS) < 1)
			settings->set(SettingsManager::MAX_MCN_UPLOADS, AirUtil::getSlotsPerUser(false, Util::toDouble(SETTING(UPLOAD_SPEED))));*/
	}	
}
LRESULT SpeedPage::checkMCN(WORD wNotifyCode, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	validateMCNLimits(wNotifyCode);
	return TRUE;
}