In Windows 7 x64, la barra di stato non visualizza il testo per i pannelli a partire correttamente dal 11 °

StackOverflow https://stackoverflow.com/questions/5325137

Domanda

riepilogo:
(1) Questo è molto probabile che sia un bug. Tuttavia, non posso dire con certezza se sia più legato alla 64 bit del sistema operativo, o VCL, o MFC wrapper. Si prega di verificare le risposte e commenti di seguito da parte di esperti di Delphi.
(2) Soluzione alternativa per me:
un. La situazione è che ho six pairs valore-chiave per mostrare nella barra di stato. I valori saranno modificati in fase di esecuzione.
b. Sembra che io non posso set text per più di pannelli 10.
c. A questo proposito, userò le chiamate six di set text per i valori, e chiede l'uso two per set text per gli ultimi due chiavi. Così, non deve superare il limite 10.
d. Al fine di rendere il lavoro set text, ho bisogno di fornire un testo diverso che ha già.
e. codice di esempio può quindi essere descritto come:

// 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'

=============================================== ===================

Nel mio Windows 7 X64, la barra di stato non visualizza il testo per i pannelli a partire correttamente dal 11 °.

(1) Nuovo un without progetto di applicazione VCL vuota salvarlo, se ho impostato il testo per il pannello di stato 11 ° in fase di progettazione, il testo non verrà mostrato a tutti in fase di esecuzione. (Vedi le immagini allegate).

(2) Se salvo e riaprirlo, il testo sarà, inoltre, non essere mostrato in fase di progettazione.

(3) Se ho impostato il testo in fase di esecuzione, il testo viene visualizzato solo quando il nuovo testo è diverso da quello vecchio. Pronunciare il testo per il pannello 11 è impostato su 'try' in fase di progettazione:

Self.stat1.Panels[10].Text := 'try';         // 'try' is not shown   
self.stat1.Panels[10].Text := 'try_';        // 'try_' is shown

(4) Questo comportamento si verifica solo sul mio Windows 7 x64, ma non sul mio Windows XP.

(5) Vorrei pensare le stesse allpies comportamento a tutte le versioni di Delphi.

(6) Sembra che il comportamento è più legata alla versione di Windows che a Delfi. Voglio dire, la stessa applicazione di esempio verrà mostrato il comportamento precedente su Windows 7, ma non su Windows XP.

(7) Un esempio di file DFM viene scaricato come di seguito:

    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

(8) Immagini del campione:
designtime
rumtime

Potrebbe qualcuno aiuto per commentare sul possibile motivo? Ogni suggerimento è apprezzato!

È stato utile?

Soluzione

I wanted to say "It works for me, on windows 7, 64 bit, with delphi XE." In fact, it did work, the first time I dropped it onto the form, it all worked great. And I thought, you're doing something wrong. Then it hit me, after the second time, I reopened the form.

Now it always fails.

I think you should start with a new blank project like I did, and do just the one thing. That takes all the other things you did out of the code, that are messing you up.

I call this the "file new" test. If you can't reproduce something in a new application, that contains only the code or controls you are unsure about, don't bother asking anybody else to do it for you.

enter image description here

Here is my initial try, it worked:

Second time I reopened the form, it failed at designtime, the same way it failed for David H.

Dump the widths of the panels to a memo like this:

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;

The VCL Status Bar wraps an MS Common control, which either has a bug, or the VCL is wrapping it wrong. Since this doesn't happen on XP, I think you've found a new MS Common Controls bug in Win7.

Altri suggerimenti

It doesn't show beyond the 10th in design-time:

enter image description here

But at run-time is looks like this:

enter image description here

All properties set in the .dfm file.

As to why it is like this I've no idea. But since it behaves fine at run-time I don't think will cause any serious problems.


As requested by Warren, here's my .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

I found a similar problem for ownerdraw panels. DrawPanel event is not called on panels with an index > 6 in Win 7/64bit. I found that windows does not send WM_DRAWITEM message to these panels. Solution that worked in my case is to set the WS_EX_COMPOSITED style to statusbar.

procedure TForm1.FormCreate(Sender: TObject);
var
  SBHandle: THandle;
begin
  ...
  if CheckWin32Version(5, 1) then
  begin
    SBHandle:= StatusBar.Handle;
    SetWindowLong(SBHandle, GWL_EXSTYLE, GetWindowLong(SBHandle, GWL_EXSTYLE) or WS_EX_COMPOSITED);
  end;
  ...
end;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top