Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   status bar (https://www.clubdelphi.com/foros/showthread.php?t=63345)

Paulao 10-02-2009 11:03:15

status bar
 
Tengo una statusbar con 6 panels. En el ultimo panel estas escribindo el count de una query, ejempl:
1980 registros. Solo que mi jefe pedio que yo escriba tambiém despues desta informacción, que ponga asi: Filtro ativo. Hasta entonces ok, pero esta frase "Filtro ativo" hay que venir en rojo. Como puedo hacer esto, o sea, una parte en negro y otra en rojo en lo mismo panels? Gracias desde ahora!!!

Neftali [Germán.Estévez] 10-02-2009 11:48:56

¡Qué toca-pelotas, tu jefe! ¿No? :D:D:D
Supongo que la única opción es hacer el pintado tú de forma manual.
Este código lo he encontrado por Internet (no es mio); A ver si te sirve o te da una idea de cómo hacerlo.

Código Delphi [-]
procedure TfrmSubscription.StatusBarDrawPanel(vStatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
var OldColor, OldBrushColor : TColor;
    OldStyle : TFontStyles;
begin
  inherited;
  if Panel.Index = 0 then begin
    with StatusBar.Canvas do begin
      // store off the original settings
      OldColor := Font.Color;
      OldStyle := Font.Style;
      OldBrushColor := Brush.Color;
      try
        // set the Brush Color
        case SubStatus of
          stExpired: Brush.Color := clTeal;
          stCanceled: Brush.Color := clLime;
          else Brush.Color := clBtnFace;
        end;  // case SubStatus of

        // fill the panel with the brush color (ie background color)
        FillRect(Rect);

        // set the text font color / style
        Font.Color := clRed;
        Font.Style := [fsBold];

        //display the text from the panel
        TextOut(Rect.Left + 3, Rect.Top, Panel.Text);

      finally  // restore the original settings
        Font.Color := OldColor;
        Font.Style := OldStyle;
        Brush.Color := OldBrushColor;
      end;  // try/finally
    end;  // with StatusBar.Canvas do begin
  end; // if Panel.Index = 0 then begin
end;

Caro 10-02-2009 15:28:02

Hola, como te dice el amigo Neftali tienes que pintar tu utilizando el Canvas

Código Delphi [-]
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
 Statusbar.Canvas.Font.Color := clBlack;  
 Statusbar.Canvas.TextOut(Rect.Left+2, Rect.Top, '1980');
 
 StatusBar.Canvas.Refresh;
 
 Statusbar.Canvas.Font.Color := clRed;
 Statusbar.Canvas.TextOut(Rect.Left+Statusbar.Canvas.TextWidth('1980'), Rect.Top, 'Filtro ativo');
end;

y colocar la propiedad Style a psOwnerDraw de tu panel 6.

Saluditos


La franja horaria es GMT +2. Ahora son las 17:57:03.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi