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

解决方案 »

  1.   

    窗体里面的所有控件都能显示正常.
    就Form1.Caption怎么都是乱码. 这个怎么解决
      

  2.   

    设置了这代码
    忽然发现 Label 能正常显示中文
    看来有必要把button之类的caption用Label显示.....
    if (GetThreadLocale<>$0804) then//取得当前线程的地方ID
        begin
          SetThreadLocale($0804);
          SetConsoleOutputCP(936);
        end;
      

  3.   

    d7的代码转xe2有点问题.
    原生xe2在某些系统正常.
    d7转xe2的就运行不起来. 主要是别人电脑没法调试.
    所以干脆想办法d7显示中文了.
    现在实现了一部分.利用alphacontrols能支持部分控件显示中文.d7:启用alphacontrols皮肤+代码重新设置一下caption=正常显示中文
    存在问题是 Form/ComboBox 还是不支持
      

  4.   

    XE2 会出现乱码么?
    XE2 是Unicode么?
      

  5.   

    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;
      

  6.   

    uses 
      Menus, StdCtrls, ComCtrls, ExtCtrls, Dialogs...
      

  7.   

    http://www.ydtuiguang.com/wztgSEO/ydggdjw/index.html
    大家可以下载试试. 英文系统能显示大部分中文
      

  8.   

    刚遇到这个问题,把pas文件编码改成utf8即可。