Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-06-2006
Avatar de sitrico
[sitrico] sitrico is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Caracas, Venezuela
Posts: 295
Poder: 22
sitrico Va por buen camino
Red face Responder a un click en un objeto (tImage) mostrado en un tStatusBar

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
    { Private declarations }
  public
    { Public declarations }
  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;

// Aqui hago el trabajo de mostrar la imagen

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;
// falta esta funcion que no trabaja:
// img.onclick := MiOnClick;
   ImageList1.GetBitmap(ItemIndex,img.Picture.Bitmap);
   StatusBar.Canvas.Draw(px,r.Top,img.Picture.Bitmap);
Finally
   Inc(px,mrg);
   End;
End;

begin
//Limpiar las imagenes
For i := 0 to ComponentCount-1 do
   If (Components[i] is TImage) then
      If tImage(Components[i]) <> nil Then
         tImage(Components[i]).Free;
// esta rutina ignorenla sólo es una prueba y fue la forma simple de 
// contar el nro de imagenes a mostrar (una por cada checked)
j := 0;
For i := 0 to ComponentCount-1 do
   if Components[i] is TCheckBox then
      If TCheckBox(Components[i]).Checked Then
         inc(j);
// el progressBar
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;
// las imagenes
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;

// Para mover el status bar
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
StatusBar1.Refresh;
end;

// Esto es obligatorio mara meter el progressbar dentro del statusBar 
// tomado de un foro)
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;

// para mover el ProgressBar
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 )
__________________
Sitrico
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
TStatusBar jymy788 Varios 4 28-09-2007 20:04:10
TStatusbar nenufer OOP 3 18-05-2006 20:47:13
implmentar Articulo click..click..run Crash ASAPLTDA OOP 0 21-01-2006 16:16:08
Como guardar en una tabla el resultado de un query mostrado en un dbgrid luisreg OOP 3 09-10-2003 01:35:01


La franja horaria es GMT +2. Ahora son las 00:25:27.


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
Copyright 1996-2007 Club Delphi