Click here to Skip to main content
15,887,135 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
sashoalm30-Sep-09 4:29
sashoalm30-Sep-09 4:29 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 4:39
Neil Urquhart30-Sep-09 4:39 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
David Crow30-Sep-09 5:43
David Crow30-Sep-09 5:43 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 6:44
Neil Urquhart30-Sep-09 6:44 
AnswerRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
David Crow30-Sep-09 6:50
David Crow30-Sep-09 6:50 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart4-Oct-09 20:59
Neil Urquhart4-Oct-09 20:59 
GeneralRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
David Crow5-Oct-09 2:49
David Crow5-Oct-09 2:49 
AnswerRe: Using CEdit with ES_NUMBER giving "Please enter a positive integer." followed by exception. Pin
Neil Urquhart30-Sep-09 5:24
Neil Urquhart30-Sep-09 5:24 
I have found a fix !

It seems in my break point testing in DoDataExchange I had put it after the DDX_Text function. It seems that the "Please enter a positive integer." message come from inside the relvant DDX_Text function somewhere.

I was therefore able to fix the problem by intercepting the value coming from CEdit at the top of DoDataExchange with a bit of validation code. The curcial test you need is to check the text in CEdit to see if the user deleted it all, even though it uses numbers. If he did delete it all I set the text and memver variable to a default value.

I also add validation code for my values range.

void CArtConDlg::DoDataExchange(CDataExchange* pDX)
{
	// Validation vars
	CEdit *cEd ;
	CString csTxt ;

	// Validate DmInterval
	cEd = (CEdit*)GetDlgItem(IDC_EDIT_DMINTERVAL) ;
	cEd->GetWindowText(csTxt) ;
	if(csTxt.IsEmpty()) {
		m_iDmInterval = MIN_DMINTERVAL ;
		csTxt.Format("%d", m_iDmInterval) ;
		cEd->SetWindowText((LPCSTR)csTxt) ;
	} else if(m_iDmInterval < MIN_DMINTERVAL) {
		m_iDmInterval = MIN_DMINTERVAL ;
	} else if(m_iDmInterval > MAX_DMINTERVAL) {
		m_iDmInterval = MAX_DMINTERVAL ;
	}

	// Validate OneShotHours
	cEd = (CEdit*)GetDlgItem(IDC_EDIT_ONESHOTHOURS) ;
	cEd->GetWindowText(csTxt) ;
	if(csTxt.IsEmpty()) {
		m_iTmrOneShotHours = MIN_TMRONESHOTHOURS ;
		csTxt.Format("%d", m_iTmrOneShotHours) ;
		cEd->SetWindowText((LPCSTR)csTxt) ;
	} else if(m_iTmrOneShotHours < MIN_TMRONESHOTHOURS) {
		m_iTmrOneShotHours = MIN_TMRONESHOTHOURS ;
	} else if(m_iTmrOneShotHours > MAX_TMRONESHOTHOURS) {
		m_iTmrOneShotHours = MAX_TMRONESHOTHOURS ;
	}

	
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CArtConDlg)
	DDX_Control(pDX, IDC_SPIN_ONESHOTHOURS, m_ctrlSpinOneShotHours);
	DDX_Control(pDX, IDC_SPIN_DMINTERVAL, m_ctrlSpinDmInterval);
	DDX_Control(pDX, IDC_TIMERONOFF, m_ctrlTimerOn);
	DDX_Control(pDX, IDC_LIGHTSENSORDAYNIGHT, m_ctrlLightSensor);
	DDX_Control(pDX, IDC_ARTWORK, m_ctrlArtworkOn);
	DDX_Control(pDX, IDC_EDITMODELAP, m_ctrlEditModeLap);
	DDX_Control(pDX, IDC_COMMSALIVE, m_ctrlCommsAlive);
	DDX_Control(pDX, IDC_EDIT_LUMIN, m_ctrlEditLumin);
	DDX_Control(pDX, IDC_SLIDER_LUMIN, m_ctrlSliderLumin);
	DDX_Control(pDX, IDC_LIST_FADERS, m_ctrlListFaders);
	DDX_Text(pDX, IDC_EDIT_FADERUPDATETIME, m_csFaderUpdateTime);
	DDX_Text(pDX, IDC_EDIT_TOTAL_AMPS, m_csTotalAmps);
	DDX_Text(pDX, IDC_EDIT_TOTAL_AMPSPCT, m_csTotalAmpsPct);
	DDX_Radio(pDX, IDC_RADIO_MODEON, m_iTimerMode);
	DDX_Check(pDX, IDC_CHECK_TMRONESHOTONEN, m_bTmrOneShotEn);
	DDX_Check(pDX, IDC_CHECK_TMRFRI, m_bTmrFri);
	DDX_Check(pDX, IDC_CHECK_TMRMON, m_bTmrMon);
	DDX_Check(pDX, IDC_CHECK_TMRSAT, m_bTmrSat);
	DDX_Check(pDX, IDC_CHECK_TMRSUN, m_bTmrSun);
	DDX_Check(pDX, IDC_CHECK_TMRTHU, m_bTmrThu);
	DDX_Check(pDX, IDC_CHECK_TMRTUE, m_bTmrTue);
	DDX_Check(pDX, IDC_CHECK_TMRWED, m_bTmrWed);
	DDX_Text(pDX, IDC_EDIT_ONESHOTENDENDDATETIME, m_csOneShotEndDateTime);
	DDX_Radio(pDX, IDC_RADIO_DMCYCLE, m_iDisplayMode);
	DDX_Text(pDX, IDC_EDIT_DMINTERVAL, m_iDmInterval);
	DDX_Text(pDX, IDC_EDIT_DMFILE, m_csDmFile);
	DDV_MaxChars(pDX, m_csDmFile, 32);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_START, m_ctTmrStart);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_FINISH, m_ctTmrFinish);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_ONESHOTSTART, m_ctTmrOneShotStart);
	DDX_Text(pDX, IDC_EDIT_ONESHOTHOURS, m_iTmrOneShotHours);
	DDX_Radio(pDX, IDC_RADIO_DMPERIODMIN, m_iDmIntervalUnits);
	DDX_Text(pDX, IDC_EDIT_DMLASTFILE, m_csDmLastFile);
	DDX_Text(pDX, IDC_EDIT_DMLASTUPDATE, m_csDmLastFileUpdated);
	DDX_Radio(pDX, IDC_RADIO_LSORAUTO, m_iLightSensorOverRide);
	DDX_Slider(pDX, IDC_SLIDER_LUMIN, m_iSliderLumin);
	DDX_Text(pDX, IDC_EDIT_LUMIN, m_iEditLumin);
	DDX_Text(pDX, IDC_EDIT_FILE, m_csEditFile);
	//}}AFX_DATA_MAP

}

QuestionBarcode generator library Pin
Marc Soleda30-Sep-09 3:23
Marc Soleda30-Sep-09 3:23 
AnswerRe: Barcode generator library Pin
includeh1030-Sep-09 5:14
includeh1030-Sep-09 5:14 
AnswerRe: Barcode generator library Pin
Alan Balkany5-Oct-09 4:34
Alan Balkany5-Oct-09 4:34 
QuestionPure virtual Function ?? Pin
Game-point30-Sep-09 3:21
Game-point30-Sep-09 3:21 
AnswerRe: Pure virtual Function ?? Pin
David Crow30-Sep-09 3:25
David Crow30-Sep-09 3:25 
AnswerRe: Pure virtual Function ?? Pin
CPallini30-Sep-09 7:14
mveCPallini30-Sep-09 7:14 
QuestionHow to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
Kushagra Tiwari30-Sep-09 3:10
Kushagra Tiwari30-Sep-09 3:10 
AnswerRe: How to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
David Crow30-Sep-09 3:30
David Crow30-Sep-09 3:30 
AnswerRe: How to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
kilt30-Sep-09 4:30
kilt30-Sep-09 4:30 
AnswerRe: How to know that the programmatically that the current user is logged on through local machine or through Remote session ? Pin
Randor 30-Sep-09 19:49
professional Randor 30-Sep-09 19:49 
Questionhow convert char[] to LPWSTR for create file !? Pin
hadi kazemi30-Sep-09 2:34
hadi kazemi30-Sep-09 2:34 
AnswerRe: how convert char[] to LPWSTR for create file !? Pin
Hristo-Bojilov30-Sep-09 2:39
Hristo-Bojilov30-Sep-09 2:39 
AnswerRe: how convert char[] to LPWSTR for create file !? Pin
Richard MacCutchan30-Sep-09 2:44
mveRichard MacCutchan30-Sep-09 2:44 
GeneralRe: how convert char[] to LPWSTR for create file !? Pin
Joe Woodbury30-Sep-09 6:08
professionalJoe Woodbury30-Sep-09 6:08 
GeneralRe: how convert char[] to LPWSTR for create file !? Pin
Richard MacCutchan30-Sep-09 6:21
mveRichard MacCutchan30-Sep-09 6:21 
Questionsame name macro with same Pin
LoveneetSingh30-Sep-09 2:20
LoveneetSingh30-Sep-09 2:20 
AnswerRe: same name macro with same Pin
Richard MacCutchan30-Sep-09 2:45
mveRichard MacCutchan30-Sep-09 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.