String __fastcall BackOneLevel(String sSrcPath)//返回上级目录
{
int i,ii,is; String str;
for(i = sSrcPath.Length(); i > 1; i--)
{
is = sSrcPath[i-1];
if(is == 0x5C) break; // "\" 判断
}
str = "";
for(ii = 1; ii < i; ii++)
{
str += sSrcPath[ii];//合成字符串
}
return str;
}
String __fastcall FloatToStrPosition(double fInValue, int iPosition)//浮点到字符尾数可控
{
String sRv;
if(iPosition == 0)
sRv = FormatFloat("0", fInValue);
else
if(iPosition == 1)
sRv = FormatFloat("0.0", fInValue);
else
if(iPosition == 2)
sRv = FormatFloat("0.00", fInValue);
else
if(iPosition == 3)
sRv = FormatFloat("0.000", fInValue);
else
if(iPosition == 4)
sRv = FormatFloat("0.0000", fInValue);
return sRv;
}
int __fastcall tryStrToInt(String sIn)//整数检查转换
{
try
{
return sIn.ToInt();
}
catch(...)
{
return 0;
}
}
float __fastcall tryStrToFloat(String sIn)//浮点检查转换
{
try
{
return sIn.ToDouble();
}
catch(...)
{
return 0;
}
}
void __fastcall MarkIntKey(char &Key)//掩码整数键盘输入数
{
if( ! ((Key >= ‘0‘) && (Key <= ‘9‘) || (Key == 8)))
{
Key = 0;
}
}
void __fastcall MarkFloatKey(char &Key)//掩码浮点键盘输入数
{
if( ! ((Key >= ‘0‘) && (Key <= ‘9‘) || (Key == ‘.‘) || (Key == 8)))
{
Key = 0;
}
}
UINT __fastcall SwRB(UINT uiValue)//交换RB颜色
{
BYTE B0,B2; tunByteDWord sw;
sw.DWord = uiValue;
B0 = sw.Byte[0];
B2 = sw.Byte[2];
sw.Byte[0] = B2;
sw.Byte[2] = B0;
return sw.DWord;
}