MFC打包
http://hi.baidu.com/feng_hit/item/6eed6885bac20728110ef339
取反色算法:
((255 - 蓝色) × 256 × 256
+ (255 - 绿色) × 256 + 255 - 红色)
/*************************************************
Function: // OnEnChangeEditIndoor
Description: // 检查数据是否是数子 或者小数点
Calls: //
Called By: // 框架
Table Accessed: //
Table Updated: //
Input: // 无
Output: // 无
Return: // 返回TRUE.
Others: // 无
*************************************************/
void CTrafficMapDlg::OnEnChangeEditIndoor(UINT id)
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the __super::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString strID;
char cLeft;
GetDlgItem(id)->GetWindowText(strID);
if(0 == strID.Compare(CString(_T('.'))))
{
//MessageBox(_T("ERROR : . not header!"));
strID.Insert(0,_T("0"));
GetDlgItem(id)->SetWindowText(strID);
goto MOVE_END ;
}
int length = strID.GetLength();
for(int i = 0 ; i < length ; i++)
{
cLeft = strID.GetAt(i);
if(i == 0 )
{
if(cLeft == '-')
continue;
}
if (cLeft == '\0')
{
continue;
}
if((cLeft >= '0' && cLeft <= '9')||(cLeft == '.'))
{
int piont = strID.Find('.');
if(-1 != piont)
{
if(0 == piont ){
MessageBox(_T("ERROR : You are joke! "));
goto MOVE_END;
}
char number = strID.GetAt(piont - 1);
if(number >= '0' && number <= '9')
{
;
}else
{
//MessageBox(_T("ERROR : format !"));
strID.Insert(piont,_T("0"));
GetDlgItem(id)->SetWindowText(strID);
goto MOVE_END;
}
if(-1 != strID.Find('.',piont + 1))
{
//MessageBox(_T("2 . more ..."));
strID.Delete(strID.Find('.',piont + 1),1);
GetDlgItem(id)->SetWindowText(strID);
goto MOVE_END;
}
}else
continue;
}else
{
if(cLeft == '-' && i != 0)
{
strID.Delete(strID.Find('-',1),1);
GetDlgItem(id)->SetWindowText(strID);
goto MOVE_END ;
}
//CString tmp;
//tmp.Format(_T("ERROR: [%c]"),cLeft);
//MessageBox(tmp);
strID.Remove(cLeft);
GetDlgItem(id)->SetWindowText(strID);
}
}
if(id == IDC_EDIT_ALLERLANG_PRO
|| id == IDC_EDIT_USER_PRO)
OnEnChangeEditCtrlForProportion(id);
MOVE_END:
keybd_event( VK_END , MapVirtualKey(VK_END,0) , 0 , 0);
return ;
}