//==============================================================================
void SetEditCell(TStringGrid *sg,int x,int y)
{
//任一CELLS获得焦点,并可直接使用键盘输入
TGridRect myRect;
myRect.Left = x;
myRect.Top = y;
myRect.Right = x;
myRect.Bottom = y;
sg->Selection = myRect;
sg->Options<
}
//------------------------------------------------------------------------
void DeleteRow(TStringGrid *sg,int x) // 删除第x行(0...)
{
for (int y=0;y
{
TStringList *ss=new TStringList();
ss->AddStrings(sg->Cols[y]);
ss->Add("");
ss->Delete(x);
sg->Cols[y]=ss;
delete ss;
}
}
//-------------------------------------------------------------------------
int IsNum(String s)
{
try
{
s.ToInt();
return 1;
}
catch(EConvertError &s)
{
ShowMessage("不是整数!");
return 0;
}
}
//------------------------------------------------------------------------------------
void SetPaperSize(int w,int h,bool bHengXiang) // 设置缺省打印机纸张大小 w*h(*0.1mm)
{
char Device[CCHDEVICENAME];
char Driver[MAX_PATH];
char Port[32];
THandle hDMode;
PDevMode pDMode;
TPrinter *Prn = Printer();
Prn->GetPrinter(Device,Driver,Port,hDMode);
if (hDMode!=NULL)
{
pDMode=(PDevMode)GlobalLock((HGLOBAL &)hDMode);
if (pDMode!=NULL)
{
pDMode->dmPaperSize= 256;
pDMode->dmFields=pDMode->dmFields | DM_PAPERSIZE;
pDMode->dmPaperLength =h; //高 *0.1mm
pDMode->dmFields =pDMode->dmFields| DM_PAPERLENGTH;
pDMode->dmPaperWidth = w; //宽 *0.1mm
pDMode->dmFields =pDMode->dmFields| DM_PAPERWIDTH;
if(bHengXiang)
pDMode->dmOrientation=DMORIENT_LANDSCAPE;
else
pDMode->dmOrientation=DMORIENT_PORTRAIT;
}
ResetDC(Prn->Handle,pDMode);
GlobalUnlock((HGLOBAL &)hDMode);
}
}
//-------------------------------------------------------------------------------------
String SafeTrunc(const String s, int count)
{
String result;
int ws_len=count;
WideString ws(s);
do
ws= ws.SubString(1,ws_len--);
while((result=ws).Length()>count);
return result;
}
String NewGUID()
{
//产生唯一GUID
_GUID gid;
String GUID;
try
{
CreateGUID(gid); //CreateClassID()
GUID=GUIDToString(gid);
}
catch(...)
{
return "";
}
return GUID;
}
int splitstr(TStringList *value,String splitStr,String sourceStr)
{
//分隔字符串
//TStringList *value=new TStringList();
value->Text="";
//String splitStr="//\\";
//AnsiString sourceStr="asd//\\fgh//\\jkl";
int sp=splitStr.Length();
int index=0;
int pos=sourceStr.Pos(splitStr);
String tmp;
int capa=0;
while (pos>0)
{
////value->Strings[index]
tmp=sourceStr.SubString(1,pos-1);
value->Add(tmp);
////sourceStr.SubString(pos,sourceStr.Length()-pos+1);
//MessageBox(Handle,value->Strings[index].c_str(),"",MB_OK);
////sourceStr.Delete(1,pos);
sourceStr=sourceStr.SubString(pos+sp,sourceStr.Length()-pos-sp+1);
pos=sourceStr.Pos(splitStr);
index++;
}
value->Add(sourceStr);
capa=value->Count;
return capa;
/*
for(int m=0;m
*/
//value->Strings[index]=sourceStr;
//delete value;
}
void nextdlg()
{
if(Key==VK_RETURN)
{
Key=0;
SendMessage(Handle,WM_NEXTDLGCTL,0,0);
}
}
/////////////////
AnsiString ConvertHZToPY(char *as_HzString)
{
//提出汉字首字母
static int li_SecPosvalue[]={1601,1637,1833,2078,2274,2302,2433,2594,2787,3106,3212,3472,3635,3722,3730,3858,4027,4086,4390,4558,4684,4925,5249};
static char* lc_FirstLetter[] = {"A", "B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T","W","X","Y","Z"};
static char* ls_SecondSecTable =
"CJWGNSPGCGNE[Y[BTYYZDXYKYGT[JNNJQMBSGZSCYJSYY[PGKBZGY[YWJKGKLJYWKPJQHY[W[DZLSGMRYPYWWCCKZNKYYGTTNJJNYKKZYTCJNMCYLQLYPYQFQRPZSLWBTGKJFYXJWZLTBNCXJJJJTXDTTSQZYCDXXHGCK[PHFFSS[YBGXLPPBYLL[HLXS[ZM[JHSOJNGHDZQYKLGJHSGQZHXQGKEZZWYSCSCJXYEYXADZPMDSSMZJZQJYZC[J[WQJBYZPXGZNZCPWHKXHQKMWFBPBYDTJZ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J"
"YYZLWCXSZFGWYYDLYHCLJSCMBJHBLYZLYCBLYDPDQYSXQZBYTDKYXJY[CNRJMPDJGKLCLJBCTBJDDBBLBLCZQRPPXJCJLZCSHLTOLJNMDDDLNGKAQHQHJGYKHEZNMSHRP[QQJCHGMFPRXHJGDYCHGHLYRZQLCYQJNZSQTKQJYMSZSWLCFQQQXYFGGYPTQWLMCRNFKKFSYYLQBMQAMMMYXCTPSHCPTXXZZSMPHPSHMCLMLDQFYQXSZYYDYJZZHQPDSZGLSTJBCKBXYQZJSGPSXQZQZRQTBDKYXZK"
"HHGFLBCSMDLDGDZDBLZYYCXNNCSYBZBFGLZZXSWMSCCMQNJQSBDQSJTXXMBLTXZCLZSHZCXRQJGJYLXZFJPHYMZQQYDFQJJLZZNZJCDGZYGCTXMZYSCTLKPHTXHTLBJXJLXSCDQXCBBTJFQZFSLTJBTKQBXXJJLJCHCZDBZJDCZJDCPRNPQCJPFCZLCLZXZDMXMPHJSGZGSZZQLYLWTJPFSYASMCJBTZKYCWMYTCSJJLJCQLWZMALBXYFBPNLSFHTGJWEJJXXGLLJSTGSHJQLZFKCGNNNSZFDEQ"
"FHBSAQTGYLBXMMYGSZLDYDQMJJRGBJTKGDHGKBLQKBDMBYLXWCXYTTYBKMRTJZXQJBHLMHMJJZMQASLDCYXYQDLQCAFYWYXQHZ";
AnsiString result = "";
int H,L,W;
unsigned int i, stringlen = strlen(as_HzString);
int j;
for( i = 0; i < stringlen; i ++ )
{
H = (unsigned char)(as_HzString[i + 0]);
L = (unsigned char)(as_HzString[i + 1]);
if(H < 0xA1 || L < 0xA1)
{
result += as_HzString[i];
continue;
}
else
W = (H - 160) * 100 + L - 160;
if(W > 1600 && W < 5590)
{
for(j = 22; j >= 0; j --)
if(W >= li_SecPosvalue[j])
{
result += lc_FirstLetter[j];
i ++;
break;
}
continue;
}
else
{
i ++;
W = ( H - 160 - 56 )*94 + L - 161;
if(W >= 0 && W <= 3007)
result += ls_SecondSecTable[W];
else
{
result += (char)H;
result += (char)L;
}
}
}
return result;
}
String makestr(String mstr, char b, int len, bool QH)
{
int slen=mstr.Length();
String tmp="";
if(slen
if(QH)
{
tmp=AnsiString::StringOfChar(b,len-slen)+mstr;
}
else
{
tmp=mstr+AnsiString::StringOfChar(b,len-slen);
}
}
else
{
tmp=mstr;
}
return tmp;
}
String makelen(String mstr, int len)
{
if(mstr.Length()
return makestr(mstr,' ',len,false);
}
else
return mstr;
}
////以分为单位
AnsiString GetBigMoney(AnsiString s)
{
if ((s.Length()<= && (s.ToIntDef(0)==0)) return "币零元零角整";
AnsiString odxc,odxs,oszc,oscc,oscc0; int oi,oi0,i;
double ormb=StrToFloat(s); //金额小写
if (ormb==0.00) return "币零元零角整";
odxc="分角圆拾佰仟万拾佰仟亿拾佰仟万拾佰仟亿";
odxs="零壹贰叁肆伍陆柒捌玖";
oszc=FloatToStr(abs(ormb));
i=AnsiPos('.',s);
oszc.Delete(i,1); // stuf(oszc,18,1,'');
oszc=Trim(oszc); oscc=""; oi0=0;
for (oi=oszc.Length();oi>0;oi--)
{ oscc=odxc.SubString(oi0*2+1,2)+oscc; oscc=odxs.SubString(StrToInt(oszc.SubString(oi,1))*2+1,2)+oscc;
oi0++; }
oscc0="";
for (oi=1;oi<=oscc.Length();oi=oi+4)
{ if (oscc.SubString(oi,2)=="零" )
{ if ( oscc.SubString(oi+2,2)=="万" )
{ if ( oscc0.SubString(oscc0.Length()-3,4)!="亿零" )
{ if (oscc0.SubString(oscc0.Length()-1,2)=="零" )
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"万";
else oscc0=oscc0+"万"; }
continue; }
if ( oscc.SubString(oi+2,2)=="圆")
{
if (oscc0.SubString(oscc0.Length()-1,2)=="零")
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"圆";
else oscc0=oscc0+"圆";
continue;
}
if ( oscc.SubString(oi+2,2)=="亿" )
{
if (oscc0.SubString(oscc0.Length()-1,2)=="零")
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"亿";
else oscc0=oscc0+"亿";
continue; }
if (oscc0.SubString(oscc0.Length()-1,2)!="零" )
oscc0=oscc0+"零";
}
else oscc0=oscc0+oscc.SubString(oi,4);
}
if ((oscc0.SubString(oscc0.Length()-3,4)=="圆零") )
{ oscc0=oscc0.SubString(1,oscc0.Length()-2)+"整";
return oscc0; }
if ((oscc0.SubString(oscc0.Length()-3,4)=="角零" ))
{ oscc0=oscc0.SubString(1,oscc0.Length()-2)+"整";
return oscc0;
}
if ((oscc0.SubString(oscc0.Length()-1,2)=="零" ))
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"圆整";
return oscc0;
}
/////////
String UpperMoney(double jn)
{
int L , ZL , Z , U , V;
AnsiString F = "壹贰叁肆伍陆柒捌玖" ;
AnsiString G = "元万亿万拾佰仟分角" ;
AnsiString AA , B , JNS;
JNS.SetLength(255);
double je ;
if(jn<=0)
return "零" ;
je=(jn<1?jn*100:jn);
printf(JNS.c_str(),"%26.2f",je) ;
JNS=TrimRight(TrimLeft(JNS)) ;
L = StrLen(JNS.c_str()) ;
L=(jn<1?(jn<0.1?1:2):L) ;
ZL = L+1 ;
AA =AnsiString("") ;
B = AnsiString("") ;
for( ;L>0; )
{
Z = StrToInt(JNS.SubString(ZL-L,1)) ;
U = int(L/4) ;
V = L%4 ;
if( Z>0 )
{
U=(V==0?U+U-1:V+V+(U>0?7:13)) ;
AA = AA+B+F.SubString(Z+Z-1,2)+G.SubString(U,2) ;
B = "" ;
}
else
{
if(L==1)
AA=AA+"整" ;
else
{
if(V==0)
AA=AA+G.SubString(U*2-1,2);
else
AA=AA+"" ;
}
B=(V>=0?"零":"") ;
}
L=(L==4?2:L-1) ;
}
return AA ;
}
//简单加解密函数
String SimCry(String SrcStr)
{
//bfxontn加密
String pass=SrcStr;
int j=pass.Length();
char dM,eM;
String fM="";
for(int i=1;i<=j;i++)
{
dM=pass[i];
eM=(dM-i);
fM=fM + eM;
}
return fM;
}
String SimEnCry(String ESrcStr)
{
//bfxontn解密
String pass=ESrcStr;
int j=pass.Length();
char dM,eM;
String fM="";
for(int i=1;i<=j;i++)
{
dM=pass[i];
eM=(dM+i);
fM=fM + eM;
}
return fM;
}
//简单加解密函数结束
#endif // DUJUNLITOOLSCPP