GetWindowText居然会自动过滤了小数点解决方案

GetWindowText居然会自动过滤了小数点
文本编辑框 , 我想实现接受多种功能,比如:只接受小数 ,只接受整数

我的代码如下:

  OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// 检查是否非法
switch(m_type)
{
case 1: //纯数字
...................
break;

case 2: //小数
if((nChar>='0'&&nChar<='9')||nChar=='.')
{
if(nChar=='.')
{
CString str;
GetWindowText(str);
if(str.GetLength()>0)
{
if(str.Find('.')>=0)
{
SetWindowText("");
return;
}
else
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else
{
AfxMessageBox("小数点不能在第一位");
return;
}
}
else
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else //清空
{
SetWindowText("");
return;
}
break;
.........................................

对于接受小数的时候

进入:case 2, 我发现一个奇怪的现象:

第一次输入小数点的时候, str.GetLength()==0, 也就是说:mfc自动过滤掉.


这是什么原因导致的。。。。



第二个问题: 推荐一款能满足我功能的开源 文本编辑框代码

谢谢了啊

------解决方案--------------------
不会吧,你设置的难道是整数?
------解决方案--------------------
探讨
文本编辑框 , 我想实现接受多种功能,比如:只接受小数 ,只接受整数

我的代码如下:

OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// 检查是否非法
switch(m_type)
{
case 1: //纯数字
...................
break;

case 2: //小数
if((nChar……