tags:

views:

131

answers:

1

Hi. I have a TStatusBar that contains two status panels. The first one is about 100 pixels long. The second one fills the rest of the status bar width. If I try to display in this second panel strings longer than about 140 chars, it truncates them to this value.

There is any way to get over this bug?

D7, Win XP


Edit: is 126 chars.

+11  A: 

@Altar, the TStatusBar component, draw the text using the SB_SETTEXT Windows message, this is limited to draw 127 characters in WinXP.

lParam

Pointer to a null-terminated string that specifies the text to set.

If wParam is SBT_OWNERDRAW, this parameter represents 32 bits of data. The parent window must interpret the data and draw the text when it receives the WM_DRAWITEM message. In Windows XP and earlier, the text for each part is limited to 127 characters. This limitation has been removed in Windows Vista.

As workaround you can draw the text of the statusbar yourself using the OnDrawPanel event.

see this sample wich draw a 200 char text in the second panel of an TStatusBar, don't forget set the property Style of the panel to psOwnerDraw

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
var
 MyLongText: string;
 i         : Integer;
begin

  //fill an string with 200 chars
  MyLongText:= StringOfChar('-', 199)+'X';

  If Panel = StatusBar1.Panels[1] Then
      With StatusBar1.Canvas Do
        TextOut(Rect.left, Rect.top + 2, MyLongText) ;
End;
RRUZ
+1 for a very complete answer
Nat
+1. Answer accepted. Thanks!!! Why they are using that damn function???
Altar