Tengo el siguiente código (de prueba) que me permite usar un tProgresBar y Mostrar Varios tImage dentro de un tStatusBar:
Código Delphi
[-]
unit StatusBarMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ImgList, ExtCtrls, JvImageList, Buttons;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
ImageList1: TImageList;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
Edit1: TEdit;
Button1: TButton;
ProgressBar1: TProgressBar;
procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
procedure CheckBox1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure SpeedButtonClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
uses Types;
{$R *.dfm}
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
Const
mrg = 25;
Var
r : tRect;
i,j, px : Integer;
Procedure MostrarImagen(ItemIndex:Integer);
Var
img : TImage;
Begin
img := TImage.Create(StatusBar);
Try
img.Tag := ItemIndex;
img.AutoSize := False;
img.Stretch := True;
img.Height := 15;
img.Width := 15;
img.Transparent := true;
ImageList1.GetBitmap(ItemIndex,img.Picture.Bitmap);
StatusBar.Canvas.Draw(px,r.Top,img.Picture.Bitmap);
Finally
Inc(px,mrg);
End;
End;
begin
For i := 0 to ComponentCount-1 do
If (Components[i] is TImage) then
If tImage(Components[i]) <> nil Then
tImage(Components[i]).Free;
j := 0;
For i := 0 to ComponentCount-1 do
if Components[i] is TCheckBox then
If TCheckBox(Components[i]).Checked Then
inc(j);
If Panel.Index = 3 then
Begin
With ProgressBar1 do
Begin
Top := Rect.Top;
Left := Rect.Left;
Width := Rect.Right - Rect.Left;
Height := Rect.Bottom - Rect.Top;
End;
End;
If Panel.Index = 4 then
Begin
r := Rect;
px := r.left + (((r.Right - r.left)- (j * mrg)) div 2);
For i := 0 to ComponentCount-1 do
if Components[i] is TCheckBox then
If TCheckBox(Components[i]).Checked Then
MostrarImagen(TCheckBox(Components[i]).Tag);
End;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
StatusBar1.Refresh;
end;
procedure TForm1.FormCreate(Sender: TObject);
Var
ProgressBarStyle : Integer;
begin
ProgressBar1.Parent := StatusBar1;
ProgressBarStyle := GetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE);
ProgressBarStyle := ProgressBarStyle - WS_EX_STATICEDGE;
SetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE,ProgressBarStyle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ProgressBar1.StepIt;
If ProgressBar1.Position = ProgressBar1.Max Then
ProgressBar1.Position := 0;
end;
end.
Como pueden ver lo que hago es mostrar una ó más imágenes dentro de un panel de un tStatusBar (segun se seleccionen los tCheckBox) claro que no es la idea de mi aplicación pero es una prueba de lo que quiero hacer:
Segun ciertos parametros, aparecerán en el panel de la StatusBar varios iconos (tImage) con información adicional para el usuario. lo que quiero hacer es que si el usuario hace click sobre uno de esos iconos se ejecute el codigo correspondiente. Esto último no es problema (tengo acciones y las lanzo segun el tag del objeto).
Lo que sí es un problema es que los tImage no responden al click del ratón.
Disculpen lo largo
PD Uso Delphi 7 con componentes normales, se que hay por hay algunos tstatusBar especializados pero preferiría usar los normales (no dan tantos problemas

)