Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

MFC edit control question

$
0
0

Hi, I have a MFC dialog that contains a few edit controls for user inputs(parameters), I also allow selecting a txt file that contains the parameters via a button control:

so I am wondering how to update the edit controls once I have read in the parameters from a txt file. This is the code for selecting parameter file:

void CBlkContSimThldDlg::OnBnClickedGrParamFileButton()
{
	// TODO: Add your control notification handler code here

	// Create an CFileDialog instance 
	CFileDialog fileDlg( TRUE, _T(".txt"), NULL, OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY, _T("Blk Cont Sim Parameter Files (*.txt)|*.txt||"), this);
	// Initializes m_ofn structure
	fileDlg.m_ofn.lpstrTitle = _T("Select Block Content Similarity Parameter File");
	fileDlg.m_ofn.lpstrInitialDir = _T("C:\\Users\\daiyue\\Documents\\Visual Studio 2010\\Projects\\UsingVIPS\\GA Training Files");
	// Call DoModal
	if(fileDlg.DoModal() == IDOK)
	{
		m_cstrParamFileName = fileDlg.GetPathName(); // This is your selected file name with path
		AfxMessageBox(_T("Your file name is :") + m_cstrParamFileName);
		ifstream file(m_cstrParamFileName);
		copy(istream_iterator<double>(file), istream_iterator<double>(), back_inserter(m_vtrParams));

		if(m_vtrParams.size() != 6)
		{
			AfxMessageBox(_T("You need to specify 6 parameters"));
			exit(EXIT_FAILURE);
		}else{// the following member variables are associated with the edit controls
			m_fDlgGrShpWt = m_vtrParams[0];
			m_fDlgGrPosWt = m_vtrParams[1];
			m_fDlgGrTxtAttWt = m_vtrParams[2];
			m_fDlgGrContTypeWt = m_vtrParams[3];
			m_fDlgBlkContSimThld = m_vtrParams[4];
			m_fDlgGrVertDistThld = m_vtrParams[5];}
	}
}

 

Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>