Hi,
I’m using an Edit Control on an MFC dialog. That control must accept numbers only, but they are not integers!! I’d like to filter all keys pressed different than “0123456789.e-“.
I’ve done that but there should be an easiest way to do that. How can I get the code (ASCII) of a key I stroke?
Here’s the code I used:
void CDialog01::OnUpdateEDITValue()
{
CString sAux, sAux1;
float fAux = -1;
GetDlgItemText(IDC_EDIT_Value, sAux);
sscanf(sAux, "%f", &fAux);
if (fAux < 0 && !sAux.IsEmpty())
SetDlgItemText(IDC_EDIT_Time, ""
else
{
sAux1 = sAux.SpanIncluding("0123456789.e-"
if (sAux.GetLength() != sAux1.GetLength())
SetDlgItemText(IDC_EDIT_Value, sAux1);
}
}
Regards,
LnOrS
I’m using an Edit Control on an MFC dialog. That control must accept numbers only, but they are not integers!! I’d like to filter all keys pressed different than “0123456789.e-“.
I’ve done that but there should be an easiest way to do that. How can I get the code (ASCII) of a key I stroke?
Here’s the code I used:
void CDialog01::OnUpdateEDITValue()
{
CString sAux, sAux1;
float fAux = -1;
GetDlgItemText(IDC_EDIT_Value, sAux);
sscanf(sAux, "%f", &fAux);
if (fAux < 0 && !sAux.IsEmpty())
SetDlgItemText(IDC_EDIT_Time, ""
else
{
sAux1 = sAux.SpanIncluding("0123456789.e-"
if (sAux.GetLength() != sAux1.GetLength())
SetDlgItemText(IDC_EDIT_Value, sAux1);
}
}
Regards,
LnOrS