BOOL CMFCApplication1Dlg: : PreTranslateMessage (MSG * pMsg)
{
//TODO: add in this dedicated code and/or call the base class
The switch (pMsg - & gt; WParam)
{
Case VK_RETURN://VK_RETURN said is key to enter,
The UpdateData (true);//if the UpdateData (TRUE)==the control value assigned to a member variable;
//the UpdateData (FALSE)==will member variable values assigned to control,
If (password==_T (" 123456 "))
{
GetDlgItem (IDC_BUTTON1) - & gt; The EnableWindow (true);//this function allowed/prohibited specified window or control accept the mouse and keyboard input,
GetDlgItem (IDC_EDITstate) - & gt; SetWindowTextW (_T (" success "));
}
The else
{
GetDlgItem (IDC_EDITstate) - & gt; SetWindowTextW (_T (" failure "));
}
Case VK_ESCAPE:
return true;
//break;
Default:
break;
}
Return CDialogEx: : PreTranslateMessage (pMsg);
}
Void CMFCApplication1Dlg: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code
The UpdateData (true);
Sum=add1 + add2;
The UpdateData (false);
Cstrings STR, str1;
//str1=_T (" \ n ");
STR. The Format (_T (" % s % % g g g "% s %), add1, _T (" +"), add2, _T ("="), sum);
STR +=_T (" \ t \ n ");
//STR=str1 + STR;
Int lastLine=recond. LineIndex (recond. GetLineCount () + 1);//GetLineCount returns text unit lines
Recond. SetSel (lastLine + 1, lastLine + 2, 0).
Recond. ReplaceSel (STR);//
}
CodePudding user response:
Recond. SetSel (lastLine + 1, lastLine + 2, 0).Recond. ReplaceSel (STR);//
Estimation problem is in the two sentences.
Look on the debugging, SetSel was based on the characters of the unit.
CodePudding user response:
If it is process input in the edit box enter messages, overloading dialog OnOK processing,CodePudding user response:
Int lastLine=recond. LineIndex (recond. GetLineCount () + 1);//GetLineCount returns text unit linesRecond. SetSel (lastLine + 1, lastLine + 2, 0).
Serial number to obtain an estimated problem, recond. GetLineCount () to obtain the index should be SetSel serial number inside, why + 1?
CodePudding user response:
LineIndex ()Recond. SetSel (lastLine + 1, lastLine + 2, 0).
Recond. ReplaceSel (STR);//
These three functions are get for a few days didn't understand what you mean
CodePudding user response:
Int lastLine=recond. LineIndex (recond. GetLineCount () + 1);//the last characterRecond. SetSel (lastLine + 1, lastLine + 2, 0).//select the last character
Recond. ReplaceSel (STR);//replace the last character
CodePudding user response:
Additional code:Int nStartChar nEndChar;
GetEditCtrl (.) GetSel (nStartChar nEndChar);//the last
GetEditCtrl (.) SetSel (nEndChar nEndChar);//select the last
GetEditCtrl (.) ReplaceSel (prompt);//replace the
CodePudding user response:
SetSel (lastLine + 1, lastLine + 2, 0) is why add a add 2 hereCodePudding user response:
Try 6 buildings code may be a bug