Delphi 在Windows 7 X64中,状态栏不会正确显示从11开始的面板文本

Delphi 在Windows 7 X64中,状态栏不会正确显示从11开始的面板文本,delphi,windows-7,statusbar,common-controls,Delphi,Windows 7,Statusbar,Common Controls,总结: (1) 这很可能是一个bug。然而,我不能确定它是否与64位操作系统、VCL或MFC包装器更相关。请检查以下德尔福专家的答案和评论。 (2) 我的解决方法: A.情况是,我有六个键值对显示在状态栏中。这些值将在运行时更改。 B似乎我不能为超过10个面板设置文本。 C在这方面,我将对值使用set text的6次调用,对最后两个键使用set text的2次调用。因此,我不必超过10限制。 D为了使设置文本工作,我需要提供它已有的不同文本。 E因此,示例代码可以描述为: // Designti

总结:
(1) 这很可能是一个bug。然而,我不能确定它是否与64位操作系统、VCL或MFC包装器更相关。请检查以下德尔福专家的答案和评论。
(2) 我的解决方法:
A.情况是,我有六个
键值
显示在状态栏中。这些值将在运行时更改。
B似乎我不能为超过10个面板设置文本。

C在这方面,我将对值使用
set text
6次调用,对最后两个键使用
set text
2次调用。因此,我不必超过
10
限制。
D为了使
设置文本
工作,我需要提供它已有的不同文本。
E因此,示例代码可以描述为:

// Designtime
stat1.Panels[0].Text := 'Key1'
stat1.Panels[2].Text := 'Key2'
stat1.Panels[4].Text := 'Key3'
stat1.Panels[6].Text := 'Key4'
stat1.Panels[8].Text := 'Key5__'
stat1.Panels[10].Text := 'Key6__'


// runtime
stat1.Panels[1].Text := 'Value1'
stat1.Panels[3].Text := 'Value2'
stat1.Panels[5].Text := 'Value3'
stat1.Panels[6].Text := 'Value4'
stat1.Panels[9].Text := 'Value5'
stat1.Panels[11].Text := 'Value6'    

stat1.Panels[8].Text := 'Key5'
stat1.Panels[10].Text := 'Key6'
=========================================================================================================

在我的Windows 7 X64中,状态栏不会正确显示从11开始的面板文本

(一) 新建一个空的VCL应用程序项目
而不保存它,如果我在设计时为第11个状态面板设置了文本,那么在运行时将根本不会显示文本。(见附图。)

(二) 如果保存并重新打开它,文本也不会在设计时显示

(三) 如果在运行时设置文本,则仅当新文本与旧文本不同时才会显示文本。假设第11个面板的文本在设计时设置为“尝试”:

Self.stat1.Panels[10].Text := 'try';         // 'try' is not shown   
self.stat1.Panels[10].Text := 'try_';        // 'try_' is shown
(四) 此行为仅在我的Windows 7 X64上发生,但在我的Windows XP上不发生

(五) 我认为相同的行为适用于所有Delphi版本

(六) 似乎这种行为更多地与Windows版本相关,而不是与Delphi相关。我的意思是,相同的示例应用程序将在Windows7上显示上述行为,但在WindowsXP上不会

(七) 示例dfm文件转储如下:

    object Form3: TForm3
      Left = 0
      Top = 0
      Caption = 'Form3'
      ClientHeight = 202
      ClientWidth = 731
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object stat1: TStatusBar
        Left = 0
        Top = 183
        Width = 731
        Height = 19
        Panels = <
          item
            Text = '0'
            Width = 50
          end
          item
            Text = '1'
            Width = 50
          end
          item
            Text = '2'
            Width = 50
          end
          item
            Text = '3'
            Width = 50
          end
          item
            Text = '4'
            Width = 50
          end
          item
            Text = '5'
            Width = 50
          end
          item
            Text = '6'
            Width = 50
          end
          item
            Text = '7'
            Width = 50
          end
          item
            Text = '8'
            Width = 50
          end
          item
            Text = '9'
            Width = 50
          end
          item
            Text = '10'
            Width = 50
          end
          item
            Text = '11'
            Width = 50
          end>
        ExplicitLeft = 248
        ExplicitTop = 152
        ExplicitWidth = 0
      end
      object btn1: TButton
        Left = 152
        Top = 40
        Width = 433
        Height = 89
        Caption = 'btn1'
        TabOrder = 1
        OnClick = btn1Click
      end
    end
对象格式3:t格式3
左=0
Top=0
标题='Form3'
ClientHeight=202
ClientWidth=731
颜色=clBtnFace
Font.Charset=默认字符集
Font.Color=clWindowText
字体高度=-11
Font.Name='Tahoma'
Font.Style=[]
OldCreateOrder=False
PixelsPerInch=96
text高度=13
对象stat1:TStatusBar
左=0
Top=183
宽度=731
高度=19
面板=<
项目
Text='0'
宽度=50
结束
项目
Text='1'
宽度=50
结束
项目
文本='2'
宽度=50
结束
项目
文本='3'
宽度=50
结束
项目
Text='4'
宽度=50
结束
项目
文本='5'
宽度=50
结束
项目
Text='6'
宽度=50
结束
项目
文本='7'
宽度=50
结束
项目
Text='8'
宽度=50
结束
项目
Text='9'
宽度=50
结束
项目
文本='10'
宽度=50
结束
项目
Text='11'
宽度=50
结束>
ExplicitLeft=248
显式t p=152
ExplicitWidth=0
结束
对象btn1:TButton
左=152
Top=40
宽度=433
高度=89
标题='btn1'
TabOrder=1
OnClick=btn1Click
结束
结束
(八) 示例图片:

有人能帮忙评论一下可能的原因吗?任何建议都将不胜感激

我想说“它对我来说很有用,在Windows7上,64位,使用delphi XE。”事实上,它确实有用,我第一次把它放到表单上时,一切都很好。我想,你做错了什么。然后它击中了我,在第二次之后,我重新打开了表格

现在它总是失败

我认为你应该像我一样从一个新的空白项目开始,只做一件事。这就把你做的所有其他事情都从代码中去掉了,把你搞砸了

我称之为“文件新”测试。如果你不能在一个新的应用程序中复制某些东西,而这个应用程序只包含你不确定的代码或控件,那么不要麻烦别人帮你做

这是我最初的尝试,它成功了:

第二次我重新打开表单时,它在设计时失败了,就像David H

将面板的宽度转储到备忘录中,如下所示:

procedure TForm3.DumpWidths;
var
 t:Integer;
begin
 for t := 0 to StatusBar1.Panels.Count-1 do begin
   Memo1.Lines.Add( '#'+IntToStr(t)+
   ' width '+
   IntToStr(StatusBar1.Panels.Items[t].Width));
 end;

end;

VCL状态栏包装MS Common控件,该控件可能有错误,或者VCL包装错误。由于XP上没有出现这种情况,我认为您在Win7中发现了一个新的MS Common Controls错误。

它在设计时间上不会超过10秒:

但在运行时,is看起来是这样的:

procedure TForm3.DumpWidths;
var
 t:Integer;
begin
 for t := 0 to StatusBar1.Panels.Count-1 do begin
   Memo1.Lines.Add( '#'+IntToStr(t)+
   ' width '+
   IntToStr(StatusBar1.Panels.Items[t].Width));
 end;

end;

在.dfm文件中设置的所有属性

至于为什么会这样,我不知道。但由于它在运行时表现良好,我认为不会导致任何严重问题


按照Warren的要求,以下是我的.dfm:

object Form3: TForm3
  Left = 0
  Top = 0
  Caption = 'Form3'
  ClientHeight = 105
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object StatusBar1: TStatusBar
    Left = 0
    Top = 86
    Width = 635
    Height = 19
    Panels = <
      item
        Text = '1'
        Width = 50
      end
      item
        Text = '2'
        Width = 50
      end
      item
        Text = '3'
        Width = 50
      end
      item
        Text = '4'
        Width = 50
      end
      item
        Text = '5'
        Width = 50
      end
      item
        Text = '6'
        Width = 50
      end
      item
        Text = '7'
        Width = 50
      end
      item
        Text = '8'
        Width = 50
      end
      item
        Text = '9'
        Width = 50
      end
      item
        Text = '10'
        Width = 50
      end
      item
        Text = '11'
        Width = 50
      end
      item
        Text = '12'
        Width = 50
      end
      item
        Text = '13'
        Width = 50
      end>
  end
end
对象格式3:t格式3
左=0
Top=0
标题='Form3'
ClientHeight=105
ClientWidth=635
颜色=clBtnFace
Font.Charset=默认字符集
Font.Color=clWindowText
字体高度=-11
Font.Name='MS Sans Serif'
Font.Style=[]
OldCreateOrder=False
PixelsPerInch=96
text高度=13
对象状态栏1:TStatusBar
左=0
Top=86
宽度=635
高度=19
面板=<
项目
Text='1'
宽度=50
结束
项目
文本='2'
宽度=50
结束
项目
文本='3'
宽度=50
结束
项目
Text='4'
宽度=50