Tema: PictureBox
Ver Mensaje Individual
  #7  
Antiguo 05-05-2006
[FGarcia] FGarcia is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Cordoba, Veracruz, México
Posts: 1.123
Reputación: 22
FGarcia Va por buen camino
Uff! Que sigue con PaintBox?

Saludos !
Pues siguiendo el consejo investigue un poco del PaintBox en delphi 7 y llegue a esto:


Código Delphi [-]
unit Plot;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls;
type
  TForm1 = class(TForm)
    Plotter: TPaintBox;
    tbSetpoint: TTrackBar;
    tbProceso: TTrackBar;
    tbSalida: TTrackBar;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure PlotterPaint(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  x, y: integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
 tbsetpoint.Position := 75;
 tbProceso.Position := 50;
 tbSalida.Position := 25;
 Label1.Color := clBlack;
 Label2.Color := clBlack;
 Label3.Color := clBlack;
 Label1.Font.Color := clYellow;
 Label2.Font.Color := clLime;
 Label3.Font.Color := clRed;
 Label1.Caption := 'Setpoint:' + ' ' + IntTostr( tbSetpoint.Position );
 Label2.Caption := 'Proceso:' + ' ' + IntTostr( tbSetpoint.Position );
 Label3.Caption := 'Salida:' + ' ' + IntTostr( tbSetpoint.Position );
 with Plotter.Canvas do
  begin
    Brush.Color := clBlack;
    Pen.Width := 5;
    FillRect(Plotter.Canvas.ClipRect );
    Rectangle(48,20,Width, Height);
  end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  //incremento en 1 la posicion en el eje de las X
  x := x + 1;
  //Verificamos si los valores cambiaron y dibujamos
  Label1.Caption := 'Setpoint:' + IntTostr( tbSetpoint.Position );
  Plotter.Canvas.Pixels[x, Plotter.Height - (tbSetpoint.Position * 2)] := clYellow;
  Label2.Caption := 'Proceso:' + IntTostr( tbProceso.Position );
  Plotter.Canvas.Pixels[x, Plotter.Height - (tbProceso.Position * 2)] := clLime;
  Label3.Caption := 'Salida:' + IntTostr( tbSalida.Position );
  Plotter.Canvas.Pixels[x, Plotter.Height - (tbSalida.Position * 2)] := clRed;
end;
procedure TForm1.PlotterPaint(Sender: TObject);
begin
   Plotter.Canvas.Rectangle (0,0,Width, Height);
   Plotter.Canvas.Pixels[x, Plotter.Height - (tbSetpoint.Position * 2)] := clYellow;
   Plotter.Canvas.Pixels[x, Plotter.Height - (tbProceso.Position * 2)] := clLime;
   Plotter.Canvas.Pixels[x, Plotter.Height - (tbSalida.Position * 2)] := clRed;
end;
 
end.




El Form:


Código Delphi [-]
object Form1: TForm1
  Left = 248
  Top = 187
  Width = 400
  Height = 272
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Plotter: TPaintBox
    Left = 8
    Top = 8
    Width = 210
    Height = 200
    Color = clBlack
    ParentColor = False
    OnPaint = PlotterPaint
  end
  object Label1: TLabel
    Left = 240
    Top = 8
    Width = 39
    Height = 13
    Caption = 'Setpoint'
  end
  object Label2: TLabel
    Left = 240
    Top = 72
    Width = 39
    Height = 13
    Caption = 'Proceso'
  end
  object Label3: TLabel
    Left = 240
    Top = 136
    Width = 29
    Height = 13
    Caption = 'Salida'
  end
  object tbSetpoint: TTrackBar
    Left = 232
    Top = 24
    Width = 150
    Height = 45
    LineSize = 2
    Max = 100
    TabOrder = 0
  end
  object tbProceso: TTrackBar
    Left = 232
    Top = 88
    Width = 150
    Height = 45
    LineSize = 2
    Max = 100
    TabOrder = 1
  end
  object tbSalida: TTrackBar
    Left = 232
    Top = 152
    Width = 150
    Height = 45
    LineSize = 2
    Max = 100
    TabOrder = 2
  end
  object Timer1: TTimer
    Interval = 500
    OnTimer = Timer1Timer
    Left = 24
    Top = 16
  end
end




y Bueno ya dibuja los puntos que quiero, ahora bien cuando llega el trazo hasta el final del PaintBox ¿como hago para que lo que ya esta dibujado se desplaze hacia la izquierda y me permita seguir viendo los nuevos trazos?

Sinceramente ya no le encuentro! Gracias por la atencion y la ayuda!!

Última edición por roman fecha: 06-05-2006 a las 07:47:59.
Responder Con Cita