unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ftdata, ExtCtrls;

type
  TForm3 = class(TForm)
    PaintBox1: TPaintBox;
    procedure PaintBox1Paint(Sender: TObject);
    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
    Table:PsingleArray;
    HighElement:longint;Min,mid,Max:single;
    procedure SetLevel(X, Y: Integer);
    procedure Redraw;
  end;

var
  Form3: TForm3;
  var form3Dup:Tform3;
implementation

{$R *.DFM}
procedure TForm3.PaintBox1Paint(Sender: TObject);
begin
 redraw;
end;
procedure tform3.Redraw;
var n,x,cy:longint;
begin
 if table=nil then exit;

 cy:=paintbox1.height-round( paintbox1.height*(mid-Min)/(max-min) );
 paintbox1.canvas.pen.mode:=pmNop;
 for n:=0 to HighElement do with paintbox1.canvas do begin
  x:=n*paintbox1.width div (HighElement+1);
  {pen.color:=clWhite;
  moveto(x,0);lineto(x,height);
  pen.color:=clBlack;
  moveto(x,height div 2);
  lineto(x,height div 2-round(table[n]*(height div 2)));}

  brush.color:=clWhite;
  fillrect(rect(x,0,x+paintbox1.width div (HighElement+1) -1,paintbox1.height));
  brush.color:=clBlack;
  fillrect(rect(x,cy,x+paintbox1.width div (HighElement+1)-1,paintbox1.height-round( paintbox1.height*(table^[n]-Min)/(max-min) )));
 end;
end;
procedure TForm3.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);

begin
SetLevel(x,y);
end;
procedure Tform3.SetLevel(X, Y: Integer);

var n:longint;
begin
if table=nil then exit;

n:=x*(HighElement+1) div paintbox1.width;
if n<0 then n:=0 else if n>(HighElement) then n:=HighElement;
table^[n]:=(1-y/paintbox1.height)*(max-min) +min;
redraw;
end;
procedure TForm3.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if ssLeft in Shift then SetLevel(x,y);
end;

end.
