分享
 
 
 

C++Builder 自编常用函数库(2)

王朝c/c++·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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<<goEditing;

SendMessage(sg->Handle,WM_LBUTTONDOWN,0,0);

}

//------------------------------------------------------------------------

void DeleteRow(TStringGrid *sg,int x) // 删除第x行(0...)

{

for (int y=0;y<sg->ColCount;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<capa;m++)

MessageBox(Handle,value->Strings[m].c_str(),"",MB_OK);

*/

//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[DZLSGMRYPYWWCCKZNKYYGTTNJJNYKKZYTCJNMCYLQLYPYQFQRPZSLWBTGKJFYXJWZLTB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ECLLKJLQJAQNBDKKGHPJTZQKSECSHALQFMMGJNLYJBBTMLYZXDCJPLDLPCQDHZYCBZSCZBZMSLJFLKRZJSNFRGJHXPDHYJYBZGDLQCSEZGXLBLGYXTWMABCHECMWYJYZLLJJYHLG[DJLSLYGKDZPZXJ"

"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<len)

{

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()<len)

{

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有