I am trying to set up a MFC C++ App in Visual Studio 2019 such that modifies the user's text as they are typing.
Current layout is 2 radio buttons,
ID= rdbOn
(set to Group = True
, with Value int variable m_isOn
= 1
)
ID= rdbOff
, m_isOn
value would be = 0
and 1 Edit Control,
ID= txtInputBox
, with Value CString
variable m_inputString
Currently, for testing I can see how it would work for a button on click, it would take something like the following and just SetDlgItemText
of the result. But that would be after they have typed, not WHILE they are typing.
void Onsomebtnclick()
{
//convert CString to String of m_inputString
//do some string manipulation
//convert back to CString
//SetDlgItemText(txtInputBox, result)
}
Update:
got EN_CHANGE
to work
I was able to get EN_CHANGE
working with the flag suggestion from user @GoGoWorx. However, now I just have a slight problem that the cursor is back to the beginning of the edit control txtInput
.
I'm reading about using a CEdit::SetSel
but don't know how to use that directly in my code. I tried
CEdit control MFC, placing cursor to end of string after SetWindowText
someDlg::someFunction()
{
//some logic stuff to get a result string
SetDlgItemText(txtInputBox, result);
//need it to set the cursor to the end
//I tried these, but it didn't recognize (expression must have class type?)
//txtInputBox.SetSel(0, -1);
//txtInputBox.SetSel(-1);
}