delphi 中文在英文系统乱码问题. 为什么属性caption加中文会乱码.代码设置caption中文就正常?

z109876543210 2012-09-02 11:10:34
delphi 中文在英文系统乱码问题. 为什么属性caption加中文会乱码.代码设置caption中文就正常?
...全文
1241 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
djunny 2013-02-04
  • 打赏
  • 举报
回复
刚遇到这个问题,把pas文件编码改成utf8即可。
z109876543210 2012-09-04
  • 打赏
  • 举报
回复
http://www.ydtuiguang.com/wztgSEO/ydggdjw/index.html
大家可以下载试试. 英文系统能显示大部分中文
minizhuxianchun 2012-09-03
  • 打赏
  • 举报
回复
用Unicode吧
z109876543210 2012-09-03
  • 打赏
  • 举报
回复
uses
Menus, StdCtrls, ComCtrls, ExtCtrls, Dialogs...
z109876543210 2012-09-03
  • 打赏
  • 举报
回复
xe2 不会有乱码



//生成重设控件Caption等属性代码


s := '';
for i := 0 to Screen.FormCount - 1 do
for j := 0 to Screen.Forms[i].ComponentCount - 1 do
begin
if Screen.Forms[i].Components[j].Name = '' then continue;
if Screen.Forms[i].Components[j] is TButton then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Caption := ''' + TButton(Screen.Forms[i].Components[j]).Caption + ''';' + #13#10;

if Screen.Forms[i].Components[j] is TLabel then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Caption := ''' + TLabel(Screen.Forms[i].Components[j]).Caption + ''';' + #13#10;

if Screen.Forms[i].Components[j] is TCheckBox then
begin
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Caption := ''' + TCheckBox(Screen.Forms[i].Components[j]).Caption + ''';' + #13#10;
if (Screen.Forms[i].Name = 'Form2') and (
(Screen.Forms[i].Components[j].Name = 'CheckBox5') or
(Screen.Forms[i].Components[j].Name = 'CheckBox6') or
(Screen.Forms[i].Components[j].Name = 'CheckBox7')
)
then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Hint := ''' + TCheckBox(Screen.Forms[i].Components[j]).Hint + ''';' + #13#10;
end;

if Screen.Forms[i].Components[j] is TGroupBox then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Caption := ''' + TGroupBox(Screen.Forms[i].Components[j]).Caption + ''';' + #13#10;

if Screen.Forms[i].Components[j] is TTabSheet then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Caption := ''' + TTabSheet(Screen.Forms[i].Components[j]).Caption + ''';' + #13#10;

if Screen.Forms[i].Components[j] is TMenuItem then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Caption := ''' + TMenuItem(Screen.Forms[i].Components[j]).Caption + ''';' + #13#10;

if (Screen.Forms[i].Name = 'Form5') and (Screen.Forms[i].Components[j].Name = 'Memo1') then
if Screen.Forms[i].Components[j] is TMemo then
for k := 0 to TMemo(Screen.Forms[i].Components[j]).Lines.Count - 1 do
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Lines.Strings[' + inttostr(k) + '] := ''' + TMemo(Screen.Forms[i].Components[j]).Lines.Strings[k] + ''';' + #13#10;

if (Screen.Forms[i].Name = 'Form2') and (
(Screen.Forms[i].Components[j].Name = 'Image3') or
(Screen.Forms[i].Components[j].Name = 'Image4') or
(Screen.Forms[i].Components[j].Name = 'Image5')
)
then
if Screen.Forms[i].Components[j] is TImage then
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Hint := ''' + TImage(Screen.Forms[i].Components[j]).Hint + ''';' + #13#10;

if (
(Screen.Forms[i].Name = 'Form1') and (
(Screen.Forms[i].Components[j].Name = 'ComboBox3') or
(Screen.Forms[i].Components[j].Name = 'ComboBox4') or
(Screen.Forms[i].Components[j].Name = 'ComboBox6')
)
) or
(
(Screen.Forms[i].Name = 'Form2') and (
(Screen.Forms[i].Components[j].Name = 'ComboBox2') or
(Screen.Forms[i].Components[j].Name = 'ComboBox3')
)
)
then
if Screen.Forms[i].Components[j] is TComboBox then
begin
for k := 0 to TComboBox(Screen.Forms[i].Components[j]).Items.Count - 1 do
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Items.Strings[' + inttostr(k) + '] := ''' + TComboBox(Screen.Forms[i].Components[j]).Items.Strings[k] + ''';' + #13#10;
end;

if Screen.Forms[i].Components[j] is TStatusBar then
begin
for k := 0 to TStatusBar(Screen.Forms[i].Components[j]).Panels.Count - 1 do
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Panels[' + inttostr(k) + '].Text := ''' + TStatusBar(Screen.Forms[i].Components[j]).Panels[k].Text + ''';' + #13#10;
end;

if Screen.Forms[i].Components[j] is TListView then
begin
for k := 0 to TListView(Screen.Forms[i].Components[j]).Columns.Count - 1 do
s := s + Screen.Forms[i].Name + '.' + Screen.Forms[i].Components[j].Name + '.Columns[' + inttostr(k) + '].Caption := ''' + TListView(Screen.Forms[i].Components[j]).Columns[k].Caption + ''';' + #13#10;
end;
end;

w7 2012-09-03
  • 打赏
  • 举报
回复
XE2 会出现乱码么?
XE2 是Unicode么?
kaikai_kk 2012-09-03
  • 打赏
  • 举报
回复
804意思是中文简单系统
既然软件运行于不同系统,就应该做不同的语言版本
z109876543210 2012-09-03
  • 打赏
  • 举报
回复
d7的代码转xe2有点问题.
原生xe2在某些系统正常.
d7转xe2的就运行不起来. 主要是别人电脑没法调试.
所以干脆想办法d7显示中文了.
现在实现了一部分.利用alphacontrols能支持部分控件显示中文.

d7:启用alphacontrols皮肤+代码重新设置一下caption=正常显示中文
存在问题是 Form/ComboBox 还是不支持
BambooCaep 2012-09-02
  • 打赏
  • 举报
回复
干嘛非要抱着十多年前的d7不放呢?
z109876543210 2012-09-02
  • 打赏
  • 举报
回复


设置了这代码
忽然发现 Label 能正常显示中文
看来有必要把button之类的caption用Label显示.....
if (GetThreadLocale<>$0804) then//取得当前线程的地方ID
begin
SetThreadLocale($0804);
SetConsoleOutputCP(936);
end;
z109876543210 2012-09-02
  • 打赏
  • 举报
回复
窗体里面的所有控件都能显示正常.
就Form1.Caption怎么都是乱码. 这个怎么解决
山东蓝鸟贵薪 2012-09-02
  • 打赏
  • 举报
回复
不太清楚,只为顶顶帖子的

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧