procedure Tfrmzh.FormActivate(Sender: TObject); var reg:tregistry; str:string; i:integer; begin //窗口活动 if dm.yy<>'' then exit; //读取注册表国家,日期类型设置 //登陆前不能读数据库!!!!!!!!@@@@@@@@@@@@@@@@@@@@@ Reg := TRegistry.Create; Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey('\Control Panel\International', false) then begin //国家 str:=Reg.readString('Locale'); if str='00000404' then dm.yy:='BIG5' else dm.yy:='GB'; if (Reg.readString('iCalendarType')='4') and (str='00000404') then begin //民国历(2002-1911=91) dm.mg:=1911; dm.mgstr:='1911'; end else begin //公元历 dm.mg:=0; dm.mgstr:='0'; end; //showmessage(str); Reg.CloseKey; end; //遍历所有窗口 //临时 //dm.yy:='BIG5'; if dm.yy<>'GB' then dm.hz; for i:=0 to application.ComponentCount-1 do begin str:=application.Components[i].Name; if str='' then continue; if application.Components[i] is tform then begin //标题汉字 dm.bthz(application.Components[i]); //GB-BIG5 if dm.yy<>'GB' then dm.GB2BIG5(application.Components[i]); end; end; if dm.yy='GB' then //if fileexists('d:') then dm.listbt.SaveToFile('d:\listbt.txt'); //上次连接过,则没有登陆画面 end;
procedure Tdm.GB2BIG5(ck: tobject); var i:integer; zj:TComponent;//组件 begin //GB-->BIG5 //if dm.yy='GB' then exit; //窗口 if (ck as tform).Tag=1 then exit; (ck as tform).Caption:= gb.GBtoBIG5( (ck as tform).Caption); //窗口上的组件 for i:=0 to (ck as tform).ComponentCount-1 do begin zj:=(ck as tform).Components[i]; //tlabel if zj is tlabel then (zj as tlabel).Caption:= gb.GBtoBIG5( (zj as tlabel).Caption); //tqrlabel if zj is tqrlabel then (zj as tqrlabel).Caption:= gb.GBtoBIG5( (zj as tqrlabel).Caption); //tfield if zj is tfield then (zj as tfield).DisplayLabel:= gb.GBtoBIG5( (zj as tfield).DisplayLabel); //tbutton if zj is tbutton then (zj as tbutton).Caption:= gb.GBtoBIG5( (zj as tbutton).Caption); //taction if zj is taction then (zj as taction).Caption:= gb.GBtoBIG5( (zj as taction).Caption); //ttabsheet if zj is ttabsheet then (zj as ttabsheet).Caption:= gb.GBtoBIG5( (zj as ttabsheet).Caption); //tcheckbox if zj is tcheckbox then (zj as tcheckbox).Caption:= gb.GBtoBIG5( (zj as tcheckbox).Caption); //TlineSeries if zj is TlineSeries then (zj as TlineSeries).Title:= gb.GBtoBIG5( (zj as TlineSeries).Title); //THorizBarSeries if zj is THorizBarSeries then (zj as THorizBarSeries).Title:= gb.GBtoBIG5( (zj as THorizBarSeries).Title); //TBarSeries if zj is TBarSeries then (zj as TBarSeries).Title:= gb.GBtoBIG5( (zj as TBarSeries).Title); //tdbcheckbox if zj is tdbcheckbox then (zj as tdbcheckbox).Caption:= gb.GBtoBIG5( (zj as tdbcheckbox).Caption); //tcombobox if zj is tcombobox then (zj as tcombobox).items.CommaText:= gb.GBtoBIG5( (zj as tcombobox).items.CommaText); //tdbnavigator if zj is tdbnavigator then (zj as tdbnavigator).hints.CommaText:= gb.GBtoBIG5( (zj as tdbnavigator).hints.CommaText); end; (ck as tform).Tag:=1; end; procedure Tdm.bthz(ck: tobject); var i:integer; zj:TComponent;//组件 str:string; begin //形成标题汉字 //窗口上的组件 str:=(ck as tform).Name+'.caption:='+''''+(ck as tform).Caption+''''+';'; listbt.Add(str); for i:=0 to (ck as tform).ComponentCount-1 do begin zj:=(ck as tform).Components[i]; str:=(ck as tform).Name+'.'+(ck as tform).Components[i].Name+'.'; //tlabel if zj is tlabel then str:=str+'caption:='+''''+(zj as tlabel).Caption+''''+';'; //tqrlabel if zj is tqrlabel then str:=str+'caption:='+''''+(zj as tqrlabel).Caption+''''+';'; //tfield if zj is tfield then begin str:=str+'DisplayLabel:='+''''+(zj as tfield).DisplayLabel+''''+';'; //字段类型,显示方式 if (zj as tfield).DataType=ftbcd then (zj as tbcdfield).Displayformat:='###,###,###.##'; if (zj as tfield).DataType=ftinteger then (zj as tintegerfield).Displayformat:='###,###,###'; if (zj as tfield).DataType=ftdatetime then (zj as tdatetimefield).Displayformat:='YYYY-M-D'; end; //tbutton if zj is tbutton then str:=str+'Caption:='+''''+(zj as tbutton).Caption+''''+';'; //taction if zj is taction then str:=str+'Caption:='+''''+(zj as taction).Caption+''''+';'; //ttabsheet if zj is ttabsheet then str:=str+'Caption:='+''''+(zj as ttabsheet).Caption+''''+';'; //tcheckbox if zj is tcheckbox then str:=str+'Caption:='+''''+(zj as tcheckbox).Caption+''''+';'; //tdbcheckbox if zj is tdbcheckbox then str:=str+'Caption:='+''''+(zj as tdbcheckbox).Caption+''''+';'; //tcombobox if zj is tcombobox then begin str:=str+'items.CommaText:='+''''; str:=str+(zj as tcombobox).Items.CommaText; str:=str+''''+';'; end; //TlineSeries if zj is TlineSeries then str:=str+'title:='+''''+(zj as TlineSeries).title+''''+';'; //THorizBarSeries if zj is THorizBarSeries then str:=str+'title:='+''''+(zj as THorizBarSeries).title+''''+';'; //TBarSeries if zj is TBarSeries then str:=str+'title:='+''''+(zj as TBarSeries).title+''''+';'; //tdbnavigator if zj is tdbnavigator then begin str:=str+'hints.CommaText:='+''''; str:=str+'首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新'; str:=str+''''+';'; (zj as tdbnavigator).ShowHint:=true; (zj as tdbnavigator).Hints.CommaText:= '首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新'; end; //标题列表,源程序 if pos('=',str)<>0 then listbt.Add(str); end; end; listbt:tstringlist;//控件标题 procedure Tdm.DataModuleCreate(Sender: TObject); begin listbt:=tstringlist.Create;end; //差不多都在这里了,看不懂再问我
一般我們以Binary方式讀入是不是有亂碼問題的.如果真還有問題的話可以到MSN:[email protected]探討.
你應該在簡體中作 "简体转换成繁体" 啊!!!
为了保证在客户那里能正常使用,我们都是在繁体操作系统中测试,现在数据显示的都是乱码,怎么给客户用啊。:(
另外,嘿嘿,我可以算是老一代的玩家了,什么沙丘啦、鬼屋啦都玩过,三国当然也玩过啦。
客户的要求也不高,他们只要显示出来的是繁体的,不要乱码就可以了,词的不同,都无所谓的啦,反正都知道是什么意思.内码转换工具太麻烦了,因为软件是为客户订做的,所以客户的很多要求,都是要满足的,不然就活不下去啦.
带控件的原码!!!! 百分百保证!!!!!!!!!!!!!!!!!!!!!!!!!!!!!http://www.csdn.net/cnshare/soft/16/16635.shtm
我已经解决了这个问题
当然,要用这个控件
但是还不够
是先要把所有控件标题以语句的形式写下来
如同:
frmzh.qrypjlx.DisplayLabel:='票据类型';
frmzh.qrypjamtn.DisplayLabel:='前一天余额';
frmzh.qrypjsp.DisplayLabel:='收票';
frmzh.qrypjdx.DisplayLabel:='兑现';
frmzh.qrypjye.DisplayLabel:='今天余额';
frmdl.caption:='登录数据库';
frmdl.lblserver.caption:='服务器地址';
frmdl.lblsjkmm.caption:='数据库密码';
frmdl.lblzh.caption:='数据库帐号';
frmdl.btnlj.Caption:='连接';
frmdl.lblygmm.caption:='员工密码';
frmdl.lblyg.caption:='员工';
frmdl.lblsjk.caption:='公司别';
.......
当然,手工写太繁
我已写好了函数,太复杂,这里说不清楚
可以联系我 0512-66332230 郝霄汉
var
reg:tregistry;
str:string;
i:integer;
begin
//窗口活动
if dm.yy<>'' then exit;
//读取注册表国家,日期类型设置
//登陆前不能读数据库!!!!!!!!@@@@@@@@@@@@@@@@@@@@@
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('\Control Panel\International', false) then
begin
//国家
str:=Reg.readString('Locale');
if str='00000404' then dm.yy:='BIG5' else dm.yy:='GB';
if (Reg.readString('iCalendarType')='4') and (str='00000404') then
begin
//民国历(2002-1911=91)
dm.mg:=1911;
dm.mgstr:='1911';
end
else
begin
//公元历
dm.mg:=0;
dm.mgstr:='0';
end;
//showmessage(str);
Reg.CloseKey;
end; //遍历所有窗口
//临时
//dm.yy:='BIG5';
if dm.yy<>'GB' then dm.hz;
for i:=0 to application.ComponentCount-1 do
begin
str:=application.Components[i].Name;
if str='' then continue;
if application.Components[i] is tform then
begin
//标题汉字
dm.bthz(application.Components[i]);
//GB-BIG5
if dm.yy<>'GB' then
dm.GB2BIG5(application.Components[i]);
end;
end;
if dm.yy='GB' then
//if fileexists('d:') then
dm.listbt.SaveToFile('d:\listbt.txt');
//上次连接过,则没有登陆画面
end;
begin
frmzh.caption:='帐户资金';
frmzh.Label1.caption:='日期';
frmzh.btncx.Caption:='查询';
frmzh.Button1.Caption:='报表';
frmzh.Button2.Caption:='导出Excel';
frmzh.Button3.Caption:='登录';
frmzh.DBNavigator1.hints.CommaText:='首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新';
frmzh.DBNavigator2.hints.CommaText:='首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新';
frmzh.DBNavigator3.hints.CommaText:='首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新';
frmzh.DBNavigator4.hints.CommaText:='首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新';
frmzh.qryzhbacc_no.DisplayLabel:='帐户代号';
frmzh.qryzhamtn.DisplayLabel:='前一天余额';
end;
//其中,内容来自 d:\list.txt
var
i:integer;
zj:TComponent;//组件
begin
//GB-->BIG5
//if dm.yy='GB' then exit;
//窗口
if (ck as tform).Tag=1 then exit;
(ck as tform).Caption:=
gb.GBtoBIG5( (ck as tform).Caption);
//窗口上的组件
for i:=0 to (ck as tform).ComponentCount-1 do
begin
zj:=(ck as tform).Components[i];
//tlabel
if zj is tlabel then
(zj as tlabel).Caption:=
gb.GBtoBIG5( (zj as tlabel).Caption);
//tqrlabel
if zj is tqrlabel then
(zj as tqrlabel).Caption:=
gb.GBtoBIG5( (zj as tqrlabel).Caption);
//tfield
if zj is tfield then
(zj as tfield).DisplayLabel:=
gb.GBtoBIG5( (zj as tfield).DisplayLabel);
//tbutton
if zj is tbutton then
(zj as tbutton).Caption:=
gb.GBtoBIG5( (zj as tbutton).Caption);
//taction
if zj is taction then
(zj as taction).Caption:=
gb.GBtoBIG5( (zj as taction).Caption);
//ttabsheet
if zj is ttabsheet then
(zj as ttabsheet).Caption:=
gb.GBtoBIG5( (zj as ttabsheet).Caption);
//tcheckbox
if zj is tcheckbox then
(zj as tcheckbox).Caption:=
gb.GBtoBIG5( (zj as tcheckbox).Caption);
//TlineSeries
if zj is TlineSeries then
(zj as TlineSeries).Title:=
gb.GBtoBIG5( (zj as TlineSeries).Title);
//THorizBarSeries
if zj is THorizBarSeries then
(zj as THorizBarSeries).Title:=
gb.GBtoBIG5( (zj as THorizBarSeries).Title);
//TBarSeries
if zj is TBarSeries then
(zj as TBarSeries).Title:=
gb.GBtoBIG5( (zj as TBarSeries).Title);
//tdbcheckbox
if zj is tdbcheckbox then
(zj as tdbcheckbox).Caption:=
gb.GBtoBIG5( (zj as tdbcheckbox).Caption);
//tcombobox
if zj is tcombobox then
(zj as tcombobox).items.CommaText:=
gb.GBtoBIG5( (zj as tcombobox).items.CommaText);
//tdbnavigator
if zj is tdbnavigator then
(zj as tdbnavigator).hints.CommaText:=
gb.GBtoBIG5( (zj as tdbnavigator).hints.CommaText);
end;
(ck as tform).Tag:=1;
end;
procedure Tdm.bthz(ck: tobject);
var
i:integer;
zj:TComponent;//组件
str:string;
begin
//形成标题汉字
//窗口上的组件
str:=(ck as tform).Name+'.caption:='+''''+(ck as tform).Caption+''''+';';
listbt.Add(str);
for i:=0 to (ck as tform).ComponentCount-1 do
begin
zj:=(ck as tform).Components[i];
str:=(ck as tform).Name+'.'+(ck as tform).Components[i].Name+'.';
//tlabel
if zj is tlabel then
str:=str+'caption:='+''''+(zj as tlabel).Caption+''''+';';
//tqrlabel
if zj is tqrlabel then
str:=str+'caption:='+''''+(zj as tqrlabel).Caption+''''+';';
//tfield
if zj is tfield then
begin
str:=str+'DisplayLabel:='+''''+(zj as tfield).DisplayLabel+''''+';';
//字段类型,显示方式
if (zj as tfield).DataType=ftbcd then
(zj as tbcdfield).Displayformat:='###,###,###.##';
if (zj as tfield).DataType=ftinteger then
(zj as tintegerfield).Displayformat:='###,###,###';
if (zj as tfield).DataType=ftdatetime then
(zj as tdatetimefield).Displayformat:='YYYY-M-D';
end;
//tbutton
if zj is tbutton then
str:=str+'Caption:='+''''+(zj as tbutton).Caption+''''+';';
//taction
if zj is taction then
str:=str+'Caption:='+''''+(zj as taction).Caption+''''+';';
//ttabsheet
if zj is ttabsheet then
str:=str+'Caption:='+''''+(zj as ttabsheet).Caption+''''+';';
//tcheckbox
if zj is tcheckbox then
str:=str+'Caption:='+''''+(zj as tcheckbox).Caption+''''+';';
//tdbcheckbox
if zj is tdbcheckbox then
str:=str+'Caption:='+''''+(zj as tdbcheckbox).Caption+''''+';';
//tcombobox
if zj is tcombobox then
begin
str:=str+'items.CommaText:='+'''';
str:=str+(zj as tcombobox).Items.CommaText;
str:=str+''''+';';
end;
//TlineSeries
if zj is TlineSeries then
str:=str+'title:='+''''+(zj as TlineSeries).title+''''+';';
//THorizBarSeries
if zj is THorizBarSeries then
str:=str+'title:='+''''+(zj as THorizBarSeries).title+''''+';';
//TBarSeries
if zj is TBarSeries then
str:=str+'title:='+''''+(zj as TBarSeries).title+''''+';';
//tdbnavigator
if zj is tdbnavigator then
begin
str:=str+'hints.CommaText:='+'''';
str:=str+'首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新';
str:=str+''''+';';
(zj as tdbnavigator).ShowHint:=true;
(zj as tdbnavigator).Hints.CommaText:=
'首记录,前一记录,下一记录,末记录,增加,删除,编辑,提交,取消,刷新';
end;
//标题列表,源程序
if pos('=',str)<>0 then listbt.Add(str);
end;
end; listbt:tstringlist;//控件标题
procedure Tdm.DataModuleCreate(Sender: TObject);
begin listbt:=tstringlist.Create;end;
//差不多都在这里了,看不懂再问我
如果没有解决,在发信给我,[email protected]
感觉要比上面的好,最重要的是方便和准确:) .ocx的控件完全的代码.一看就会:)