示例#1
0
int _tmain(int argc, TCHAR *argv[])
{
	int res = -1;
	program_state_t state;

	if (argc != 4) {
		_tprintf(_T("Usage: %s <file> <num of threads> <max chunk size (bytes)>\n"), argv[0]);
		return -1;
	}
	_tcscpy_s(state.filename, argv[1]);
	state.num_of_threads = _tstoi(argv[2]);
	state.chunk_size = _tstoi(argv[3]);

	if (!init_state(&state)) {
		goto cleanup;
	}
	if (compute_checksums(&state)) {
		// return checksum
		_tprintf(_T("Total checksum: %d"), (unsigned int)state.checksum);
		res = (unsigned int)state.checksum;
	}

cleanup:
	fini_state(&state);
	return res;
}
示例#2
0
void CCtrlButton::_ParseProperty (const tstring &key, const tstring &value, bool &relayout, bool &redraw) {
	if (key == _T("button-image")) {
		ExplodeT<TCHAR>::ValueT values = explode(_T(" "), value);
		assert(values.size() == 1 || values.size() == 2);
		uint id = _tstoi(values[0]);
		if (values.size() == 1) {
			m_imgTrans = false;
		} else {
			m_imgTrans = true;
			m_imgClrKey = _ParseColor(values[1]);
		}
		if (id != m_imgId) {
			m_imgId = id;
			redraw = true;
		}
	} else if (key == _T("button-image-text-padding")) {
		int v = _tstoi(value);
		if (v != m_text_image_pading) {
			m_text_image_pading = v;
			redraw = true;
		}
	} else {
		CControl::_ParseProperty(key, value, relayout, redraw);
	}
}
示例#3
0
文件: http_srv.cpp 项目: KWMalik/tau
int _tmain(int argc, TCHAR *argv[])
{
	int res = 0;
	program_state_t state;

	if (argc != 4) {
		_tprintf(_T("Usage: %s <port> <in folder> <num of threads>\n"), argv[0]);
		return -1;
	}
	state.port = _tstoi(argv[1]);
	_tcscpy_s(state.in_dir, argv[2]);
	state.num_of_threads = _tstoi(argv[3]);

	if (!init_state(&state)) {
		res = -1;
		goto cleanup;
	}
	if (!run_server(&state)) {
		res = -1;
	}

cleanup:
	if (!fini_state(&state)) {
		res = -1;
	}
	return res;
}
void CPPgConnection::OnEnChangeUDPDisable()
{
	if (guardian)
		return;

	uint16 tempVal = 0;
	CString strBuffer;
	TCHAR buffer[510];
	
	guardian = true;
	SetModified();

	GetDlgItem(IDC_UDPPORT)->EnableWindow(!IsDlgButtonChecked(IDC_UDPDISABLE));

	if (GetDlgItem(IDC_UDPPORT)->GetWindowTextLength())
	{
		GetDlgItem(IDC_UDPPORT)->GetWindowText(buffer, 20);
		tempVal = _tstoi(buffer);
	}
	
	if (IsDlgButtonChecked(IDC_UDPDISABLE) || (!IsDlgButtonChecked(IDC_UDPDISABLE) && tempVal == 0))
	{
		tempVal = _tstoi(buffer) ? _tstoi(buffer)+10 : thePrefs.port+10;
		if (IsDlgButtonChecked(IDC_UDPDISABLE))
			tempVal = 0;
		strBuffer.Format(_T("%d"), tempVal);
		GetDlgItem(IDC_UDPPORT)->SetWindowText(strBuffer);
	}

	guardian = false;
}
示例#5
0
// Parse two integers separated by a comma.
static void iwcmd_parse_int_pair(const TCHAR *s, int *i1, int *i2)
{
	TCHAR *cpos;

	*i1 = _tstoi(s);
	*i2 = 0;
	cpos = _tcschr(s,',');
	if(!cpos) return;
	*i2 = _tstoi(cpos+1);
}
示例#6
0
BOOL CPPgWebServer::OnApply()
{	
	if(m_bModified)
	{
		CString sBuf;
		uint16 oldPort=thePrefs.GetWSPort();

		GetDlgItem(IDC_WSPASS)->GetWindowText(sBuf);
		if(sBuf != HIDDEN_PASSWORD)
			thePrefs.SetWSPass(sBuf);
		
		GetDlgItem(IDC_WSPASSLOW)->GetWindowText(sBuf);
		if(sBuf != HIDDEN_PASSWORD)
			thePrefs.SetWSLowPass(sBuf);

		GetDlgItem(IDC_WSPORT)->GetWindowText(sBuf);
		if (_tstoi(sBuf)!=oldPort) {
			thePrefs.SetWSPort(_tstoi(sBuf));
			theApp.webserver->RestartServer();
		}
		thePrefs.SetWSIsEnabled((uint8)IsDlgButtonChecked(IDC_WSENABLED));
		thePrefs.SetWSIsLowUserEnabled((uint8)IsDlgButtonChecked(IDC_WSENABLEDLOW));
		thePrefs.SetWebUseGzip( (uint8)IsDlgButtonChecked(IDC_WS_GZIP));
		theApp.webserver->StartServer();

		GetDlgItem(IDC_TMPLPATH)->GetWindowText(sBuf);
		thePrefs.SetTemplate(sBuf);

//==> remove MobileMule [shadow2004]
#if defined(MM)
		// mobilemule
		GetDlgItem(IDC_MMPORT_FIELD)->GetWindowText(sBuf);
		if (_tstoi(sBuf)!= thePrefs.GetMMPort() ) {
			thePrefs.SetMMPort(_tstoi(sBuf));
			theApp.mmserver->StopServer();
			theApp.mmserver->Init();
		}
		thePrefs.SetMMIsEnabled((uint8)IsDlgButtonChecked(IDC_MMENABLED));
		if (IsDlgButtonChecked(IDC_MMENABLED))
			theApp.mmserver->Init();
		else
			theApp.mmserver->StopServer();
		GetDlgItem(IDC_MMPASSWORDFIELD)->GetWindowText(sBuf);
		if(sBuf != HIDDEN_PASSWORD)
			thePrefs.SetMMPass(sBuf);
#endif //MM
//<== remove MobileMule [shadow2004]

		theApp.emuledlg->serverwnd->UpdateMyInfo();
		SetModified(FALSE);
	}

	return CPropertyPage::OnApply();
}
示例#7
0
BOOL CPPgProxy::OnApply()
{
	USES_CONVERSION;
	thePrefs.SetProxyASCWOP(IsDlgButtonChecked(IDC_ASCWOP));
	proxy.UseProxy=(IsDlgButtonChecked(IDC_ENABLEPROXY));
	proxy.EnablePassword = ((CButton*)GetDlgItem(IDC_ENABLEAUTH))->GetCheck();
	proxy.type = ((CComboBox*)GetDlgItem(IDC_PROXYTYPE))->GetCurSel();

	if(GetDlgItem(IDC_PROXYNAME)->GetWindowTextLength())
	{ 
		GetDlgItem(IDC_PROXYNAME)->GetWindowText(proxy.name, ARRSIZE(proxy.name));
	}
	else
	{
		proxy.name[0] = _T('\0');
        proxy.UseProxy = false;
	}

	if(GetDlgItem(IDC_PROXYPORT)->GetWindowTextLength())
	{ 
		TCHAR buffer[6];
		GetDlgItem(IDC_PROXYPORT)->GetWindowText(buffer,ARRSIZE(buffer));
		proxy.port = (_tstoi(buffer)) ? _tstoi(buffer) : 1080;
	}
	else
		proxy.port = 1080;

	if(GetDlgItem(IDC_USERNAME_A)->GetWindowTextLength())
	{ 
		CString strUser;
		GetDlgItem(IDC_USERNAME_A)->GetWindowText(strUser);
		_snprintf(proxy.user, ARRSIZE(proxy.user), "%s", T2CA(strUser));
	}
	else
	{
		proxy.user[0] = '\0';
		proxy.EnablePassword = false;
	}

	if(GetDlgItem(IDC_PASSWORD)->GetWindowTextLength())
	{ 
		CString strPasswd;
		GetDlgItem(IDC_PASSWORD)->GetWindowText(strPasswd);
		_snprintf(proxy.password, ARRSIZE(proxy.password), "%s", T2CA(strPasswd));
	}
	else
	{
		proxy.password[0] = '\0';
		proxy.EnablePassword = false;
	}
	thePrefs.SetProxySettings(proxy);
	LoadSettings();
	return TRUE;
}
示例#8
0
void CPPgConnection::OnStartPortTest()
{
	CString buffer;

	GetDlgItem(IDC_PORT)->GetWindowText(buffer);
	uint16 tcp = (uint16)_tstoi(buffer);

	GetDlgItem(IDC_UDPPORT)->GetWindowText(buffer);
	uint16 udp = (uint16)_tstoi(buffer);

	TriggerPortTest(tcp, udp);
}
示例#9
0
//---------------------------------------------------------------------
// すべてのセルを初期化する
//---------------------------------------------------------------------
void InitCellsFromFile(SuDokuGame& sudoku, LPCTSTR fname) {
	while (!g_gameStack.empty())
		g_gameStack.pop();

	sudoku.InitCells();

	FILE* fp = _tfopen(fname, _T("r"));
	if (fp) {
		TCHAR buf[512];
		for (int y = 0; y < 9; y++) {
			if (_fgetts(buf, _countof(buf), fp) == NULL) {
				break;
			}

			for (int x = 0; x < 9; x++) {
				int num = buf[x] - '0';
				if (num != 0) {
					sudoku.FixCell(y, x, num);
				}
			}
		}

		while (1) {
			if (_fgetts(buf, _countof(buf), fp) == NULL) {
				break;
			}

			if (_tcsnicmp(_T("ExGroup="), buf, _tcslen(_T("ExGroup="))) == 0) {
				std::pair<int, int> onePair;
				std::vector<std::pair<int, int>> oneGroup;

				LPTSTR p = _tcstok(&buf[_tcslen(_T("ExGroup="))], _T(","));
				onePair.first = _tstoi(p);	// y 座標

				p = _tcstok(NULL, _T(","));
				onePair.second = _tstoi(p);	// x座標

				oneGroup.push_back(onePair);

				while ((p = _tcstok(NULL, _T(","))) != NULL) {
					onePair.first = _tstoi(p);
					p = _tcstok(NULL, _T(","));
					onePair.second = _tstoi(p);
					oneGroup.push_back(onePair);
				}

				sudoku.AddExGroup(oneGroup);
			}
		}

		fclose(fp);
	}
}
示例#10
0
bool CSourceSaver::IsExpired(CString expirationdate)
{
	int year = _tstoi(expirationdate.Mid(0, 2)) + 2000;
	int month = _tstoi(expirationdate.Mid(2, 2));
	int day = _tstoi(expirationdate.Mid(4, 2));
	//MORPH - Added by SiRoB, SLS keep only for rare files, reduce Saved Source and life time
	int hour = _tstoi(expirationdate.Mid(6, 2));
	int minute = _tstoi(expirationdate.Mid(8, 2));
	
	//MORPH - Changed by SiRoB, SLS keep only for rare files, reduce Saved Source and life time
	//CTime expiration(year, month, day, 0, 0, 0);
	CTime expiration(year, month, day, hour, minute, 0);
	return (expiration < CTime::GetCurrentTime());
}
示例#11
0
BOOL CNumericEdit::Validate(BOOL bPrompt, BOOL bFocus)
{
	if (m_iMinValue == 0 && m_iMaxValue == 0)
		return TRUE;

	CString		strText;
	GetWindowText(strText);
	int iNum = _tstoi(strText);
	if (iNum < m_iMinValue || iNum > m_iMaxValue)
	{
		if (bPrompt)
		{
			CString strPrompt;
			strPrompt.Format(GetResString(IDS_EDIT_RANGER), m_iMinValue, m_iMaxValue);
			MessageBox(strPrompt, _T("easyMule"), MB_OK);
		}
		if (bFocus)
		{
			SetFocus();
			SetSel(0, -1);
		}
		return FALSE;
	}
	return TRUE;
}
示例#12
0
void CSampleConfigDlg::OnEnChangeEditRepeation()
{
	// “重复次数”编辑框变化响应函数
	CString strRepeations;
	m_ctrlEditRepeations.GetWindowText(strRepeations);
	int dRepeations;
	dRepeations = _tstoi(strRepeations);

	if(dRepeations > 20)
	{
		dRepeations = 20;
		strRepeations.Format(_T("%d"),dRepeations);
		m_ctrlEditRepeations.SetWindowText(strRepeations);
	}

	if(dRepeations < 1)
	{
		dRepeations = 1;
		strRepeations.Format(_T("%d"),dRepeations);
		m_ctrlEditRepeations.SetWindowText(strRepeations);
	}

	POSITION pos = m_ctrlConfigList.GetFirstSelectedItemPosition();
	while (pos)
	{
		int nItem = m_ctrlConfigList.GetNextSelectedItem(pos);
		CSampleConfigListItem * pItem = reinterpret_cast<CSampleConfigListItem *>(m_ctrlConfigList.GetItemData(nItem));
		pItem->SetRepeat(dRepeations);
	}

	m_ctrlConfigList.RedrawAllItems();
}
示例#13
0
void CMainDlg::GetControlValues()
{	
	CWnd* pWnd = NULL;
	VERIFY(pWnd = (CEdit*)GetDlgItem(IDC_LINE_WIDTH));
	CString strTemp;
	pWnd->GetWindowText(strTemp);
	m_iBandPx = _tstoi(strTemp);
	VERIFY(pWnd = (CEdit*)GetDlgItem(IDC_IMAGE_PATH));
	pWnd->GetWindowText(m_strImagePath);
	if(m_strImagePath.Right(1) != _T('\\'))
		m_strImagePath += _T('\\');
	VERIFY(pWnd = GetDlgItem(IDC_IMAGE_NAME));
	pWnd->GetWindowText(m_strImageName);

	CButton* pBtn = (CButton*)GetDlgItem(IDC_MIN_TO_TRAY);
	ASSERT(pBtn);
	m_bMinToTray = pBtn->GetCheck();

	if(((CButton*)GetDlgItem(IDC_OPT_IMGNAME_1))->GetCheck() == 1)
		m_iNamingOpt = 0;
	else if(((CButton*)GetDlgItem(IDC_OPT_IMGNAME_2))->GetCheck() == 1)
		m_iNamingOpt = 1;
	else
		m_iNamingOpt = 2;
}
示例#14
0
int _tmain(int argc, _TCHAR* argv[])
{
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	IODispatcher ioService(GetFitThreadNum());
	

	try
	{
		std::string ip;
		if( argc > 1 )
			ip = CT2A(argv[1]);
		else
			ip = "127.0.0.1";

		std::vector<Client *> clis;
		size_t cnt = 1;
		if( argc > 2 )
			cnt = _tstoi(argv[2]);

		clis.resize(cnt);
		for(size_t i = 0; i != cnt; ++i)
			clis.push_back(new Client(ioService, ip.c_str(), 5050));


		system("pause");
	}
	catch(std::exception &e)
	{
		std::cout << e.what() << std::endl;
	}
	
	return 0;
}
示例#15
0
void CSampleConfigDlg::OnDeltaposSpinRepeation(NMHDR *pNMHDR, LRESULT *pResult)
{
	//“重复次数”微调按钮单击响应函数

	LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);

	CString strRepeations;
	m_ctrlEditRepeations.GetWindowText(strRepeations);

	int nRepeations;
	nRepeations = _tstoi(strRepeations);

	CString strValue;
	if(pNMUpDown->iDelta == -1)			// 如果此值为-1,即点击了Spin的向上箭头时
	{
		nRepeations += 1;
	}
	else if(pNMUpDown->iDelta == 1)		// 如果此值为1,即点击了Spin的向下箭头时
	{
		nRepeations -= 1;
	}

	strRepeations.Format(_T("%d"),nRepeations);
	m_ctrlEditRepeations.SetWindowText(strRepeations);
	*pResult = 0;
}
示例#16
0
BOOL COptionTreeItemEdit::GetEditDword(DWORD &dwReturn)
{
	// Declare variables
	CString strWindowText;

	// Set blank
	dwReturn = 0;

	// Get window text
	if (IsWindow(GetSafeHwnd()))
	{
		GetWindowText(strWindowText);
	}
	else
	{
		return FALSE;
	}

	// First see if we are in numerical mode
	if (GetOption(OT_EDIT_NUMERICAL) == FALSE)
	{
		return FALSE;
	}

	// See if string is numeric
	if (IsStringNumeric(strWindowText) == FALSE)
	{
		return FALSE;
	}

	// Convert string
	dwReturn = (DWORD) _tstoi(strWindowText);

	return TRUE;
}
示例#17
0
bool CIni::GetBool(LPCTSTR strEntry,bool bDefault/* = false*/,LPCTSTR strSection/* = NULL*/)
{
	TCHAR strDefault[MAX_PATH];
	_sntprintf(strDefault, ARRSIZE(strDefault), _T("%d"), (int)bDefault);
	GetLPCSTR(strEntry,strSection,strDefault);
	return ( _tstoi(m_chBuffer) != 0 );
}
示例#18
0
WORD CIni::GetWORD(LPCTSTR strEntry,WORD nDefault/* = 0*/,LPCTSTR strSection/* = NULL*/)
{
	TCHAR strDefault[MAX_PATH];
	_sntprintf(strDefault, ARRSIZE(strDefault), _T("%u"), nDefault);
	GetLPCSTR(strEntry,strSection,strDefault);
	return (WORD)_tstoi(m_chBuffer);
}
示例#19
0
int CIni::GetInt(LPCTSTR strEntry,int nDefault/* = 0*/,LPCTSTR strSection/* = NULL*/)
{
	TCHAR strDefault[MAX_PATH];
	_sntprintf(strDefault, ARRSIZE(strDefault), _T("%d"), nDefault);
	GetLPCSTR(strEntry,strSection,strDefault);
	return _tstoi(m_chBuffer);
}
示例#20
0
bool IniTool::GetValueBoolean( CString sSection, CString sKey, bool bDefault/*=false*/ )
{
	CString strDefault;
	strDefault.Format(_T("%d"), bDefault ? 1 : 0);
	CString sValue = this->GetValueString(sSection, sKey, strDefault);
	return (1 == _tstoi(sValue));
}
示例#21
0
文件: ini2.cpp 项目: axxapp/winxgui
void CIni::SerGet(bool bGet, WORD *ar, int nCount, LPCTSTR strEntry, LPCTSTR strSection/*=NULL*/, DWORD Default/* = 0*/)
{
	if(nCount > 0) {
		CString strBuffer;
		if(bGet) {
			strBuffer = GetString(strEntry, _T(""), strSection);
			CString strTemp;
			int nOffset = 0;
			for(int i = 0; i < nCount; i++) {
				nOffset = Parse(strBuffer, nOffset, strTemp);
				if(strTemp.GetLength() == 0)
					ar[i] = (WORD)Default;
				else
					ar[i] = (WORD)_tstoi(strTemp);
			}

		} else {
			CString strTemp;
			strBuffer.Format(_T("%d"), ar[0]);
			for(int i = 1; i < nCount; i++) {
				strTemp.Format(_T("%d"), ar[i]);
				strBuffer.AppendChar(_T(','));
				strBuffer.Append(strTemp);
			}
			WriteString(strEntry, strBuffer, strSection);
		}
	}
}
示例#22
0
int LoadRouterAuth(HTTPCSTR path) {
	FILE *RouterAuth;
	HTTPCHAR line[200];
	HTTPCHAR *p;
	//int nRouterAuth=0;
	nRouterAuth=0;

	RouterAuth=_tfopen(path,_T("r"));

	if (RouterAuth) {
		while (!feof(RouterAuth)) {
			_fgetts(line,sizeof(line)/sizeof(HTTPCHAR)-1,RouterAuth);
			if ( (_tcslen(line)>5) && line[0]!=_T('#') ) {
				p=line+_tcslen(line)-1;
				while ( (*p==_T('\r') ) || (*p==_T('\n')) || (*p==_T(' ')) ) { p[0]=_T('\0'); --p; }
				p=_tcstok(line,_T("|"));
				FakeAuth[nRouterAuth].status=_tstoi(p);
				p=_tcstok(NULL,_T("|"));
				_tcsncpy(FakeAuth[nRouterAuth].server,p,sizeof(FakeAuth[nRouterAuth].server)/sizeof(HTTPCHAR)-1);
				if ( (_tcslen(p)==1) && (p[0]==_T('*')) ) FakeAuth[nRouterAuth].server[0]=_T('\0');
				p=_tcstok(NULL,_T("|"));
				_tcsncpy(FakeAuth[nRouterAuth].authurl,p,sizeof(FakeAuth[nRouterAuth].authurl)/sizeof(HTTPCHAR)-1);
				p=_tcstok(NULL,_T("|"));
				_tcsncpy(FakeAuth[nRouterAuth].method,p,sizeof(FakeAuth[nRouterAuth].method)/sizeof(HTTPCHAR)-1);
				p=_tcstok(NULL,_T("|"));
				if (p) _tcsncpy(FakeAuth[nRouterAuth].postdata,p,sizeof(FakeAuth[nRouterAuth].postdata)/sizeof(HTTPCHAR)-1);
				nRouterAuth++;
			}
		}
		fclose(RouterAuth);
	}
	return(nRouterAuth);
}
示例#23
0
文件: SetupWnd.cpp 项目: xstarty/SPYM
BOOL CSetupWnd::LoadWndParameter(CString& strParameter)
{
	CStringArray arData;

	if (!m_edPath)
		return FALSE;

	CString sToken = _T("");
	int i = 0;
	while (AfxExtractSubString(sToken, strParameter, i, ','))
	{
		arData.Add(sToken);
		i++;
	}

	if (arData.GetCount() != $VALUE_MAX)
		return FALSE;
		
	m_btnEnable->SetCheck(_tstoi(arData.GetAt($VALUE_ENABLE)));

	CString strTemp(arData.GetAt($VALUE_PATH));
	strTemp.Replace(L"\\", L"\\\\");
	m_edPath->SetWindowText(strTemp);


	return TRUE;
}
void ReadServerErrCodeFile(std::map<uint32_t, std::map<ELanguageType, TString> >& languageServerErrCodeMap)
{
    TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language);
    filePath.append(_T("\\")).append("networkError.xml");
    if (CFilePathTool::GetInstance()->Exists(filePath.c_str()))
    {
        rapidxml::file<> fdoc(filePath.c_str());
        rapidxml::xml_document<> errCodeXML;
        try
        {
            errCodeXML.parse<rapidxml::parse_default>(fdoc.data());
        }
        catch (rapidxml::parse_error err)
        {
            BEATS_ASSERT(false, _T("Load config file %s faled!/n%s/n"), "errno.xml", err.what());
        }
        rapidxml::xml_node<>* pRootElement = errCodeXML.first_node("config");
        if (pRootElement)
        {
            for (auto element = pRootElement->first_node(); element; element = element->next_sibling())
            {
                std::map<ELanguageType, TString> curMap;
                curMap[eLT_Chinese] = element->first_attribute("lang_zhCN")->value();
                curMap[eLT_English] = element->first_attribute("lang_enUS")->value();
                languageServerErrCodeMap[_tstoi(element->first_attribute("code")->value())] = curMap;
            }
        }
    }
}
示例#25
0
/******************************************************************
Function Name:  GetNetfx10SPLevel
Description:    Uses the detection method recommended at
				http://blogs.msdn.com/astebner/archive/2004/09/14/229802.aspx
				to determine what service pack for the
				.NET Framework 1.0 is installed on the machine
Inputs:         NONE
Results:        integer representing SP level for .NET Framework 1.0
******************************************************************/
int GetNetfx10SPLevel()
{
	TCHAR szRegValue[MAX_PATH];
	TCHAR *pszSPLevel = NULL;
	int iRetValue = -1;
	bool bRegistryRetVal = false;

	// Need to detect what OS we are running on so we know what
	// registry key to use to look up the SP level
	if (IsCurrentOSTabletMedCenter())
		bRegistryRetVal = RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx10SPxOCMRegKeyName, g_szNetfxStandardVersionRegValueName, NULL, (LPBYTE)szRegValue, MAX_PATH);
	else
		bRegistryRetVal = RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx10SPxMSIRegKeyName, g_szNetfxStandardVersionRegValueName, NULL, (LPBYTE)szRegValue, MAX_PATH);

	if (bRegistryRetVal)
	{
		// This registry value should be of the format
		// #,#,#####,# where the last # is the SP level
		// Try to parse off the last # here
		pszSPLevel = _tcsrchr(szRegValue, _T(','));
		if (NULL != pszSPLevel)
		{
			// Increment the pointer to skip the comma
			pszSPLevel++;

			// Convert the remaining value to an integer
			iRetValue = _tstoi(pszSPLevel);
		}
	}

	return iRetValue;
}
示例#26
0
void CAction::GetKeyElement(CString &s,int &type,int &key)
{
    // формат примерно такой "d(ff)u(ff)"
    if(s.GetLength()<4) {
        s.Empty();
        return;
    }
    if(s.GetAt(1)!=_T('(')) {
        s.Empty();
        return;
    }
    type=-1;
    if(s.GetAt(0)==_T('d'))type=0;
    if(s.GetAt(0)==_T('u'))type=1;
    if(type==-1) {
        s.Empty();
        return;
    }
    int end=s.Find(_T(")"));
    if(end==-1) {
        s.Empty();
        return;
    }
    key=_tstoi(s.Mid(2,end-2));
    s.Delete(0,end+1);
}
示例#27
0
int IniTool::GetValueInt( CString sSection, CString sKey, int iDefault/*=0*/ )
{
	CString strDefault;
	strDefault.Format(_T("%d"), iDefault);
	CString sValue = this->GetValueString(sSection, sKey, strDefault);
	return _tstoi(sValue);
}
示例#28
0
void CInstrumentEditorDPCM::OnCbnSelchangeSamples()
{
	CComboBox *m_pSampleBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_SAMPLES));
	CComboBox *pPitchBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_PITCH));
	
	int PrevSample = m_pInstrument->GetSample(m_iOctave, m_iSelectedKey);
	int Sample = m_pSampleBox->GetCurSel();

	if (Sample > 0) {
		char Name[256];
		m_pSampleBox->GetLBText(Sample, Name);
		
		Name[2] = 0;
		if (Name[0] == _T('0')) {
			Name[0] = Name[1];
			Name[1] = 0;
		}

		Sample = _tstoi(Name);
		Sample++;

		if (PrevSample == 0) {
			int Pitch = pPitchBox->GetCurSel();
			m_pInstrument->SetSamplePitch(m_iOctave, m_iSelectedKey, Pitch);
		}
	}

	m_pInstrument->SetSample(m_iOctave, m_iSelectedKey, Sample);

	UpdateKey(m_iSelectedKey);
}
void COptionTreeWrapper::SerializeStaticItemInt(IArchive &ar, COptionTreeItem *item, bool read)
{
	int iVal;
	COptionTreeItemStatic *otiStatic;
	TCHAR buffer[50];
	CString text;

	otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);
	if(otiStatic == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(iVal);
		_itot(iVal, buffer, 10);
		otiStatic->SetStaticText(buffer);
	}
	else
	{
		text = otiStatic->GetStaticText();
		iVal = _tstoi(text);
		ar.Write(iVal);
	}
}
示例#30
0
BOOL CNumberLimitEdit::ValidityCheck(BOOL bShowMsg, BOOL bRecoverDefault)
{
	CString strValue;
	GetWindowText(strValue);

	
	if (strValue.GetLength() == 0) {
		if (bShowMsg) {
			ReportErrorMsg();
			//SetDisplayNum(m_nCurrent);
		}

		if (bRecoverDefault)
			SetDisplayNum(m_nCurrent);

		return FALSE;
	}

	int nNew = _tstoi(strValue);

	if (   m_nMin != m_nMax 
		&& (nNew < m_nMin || nNew > m_nMax) ) 
	{
		if (bShowMsg)
			ReportErrorMsg();
		if (bRecoverDefault)
			SetDisplayNum(m_nCurrent);

		return FALSE;
	}

	m_nCurrent = nNew;
	return TRUE;
}