'Resize Image on Delphi 7

I can’t resize the image, it says there is no declared identifier, despite the fact that in the middle of the code it is declared and is not considered an error, but at the end it gives this, I know that I need to write an end at the end. but that won't help at all. Please help! I accept any solution to this error.

 
// Функция для графического представления
function f(x:real):real;
begin
    f:=2*sin(x)*exp(x/5)
end;
   // процедура построения графика
procedure GrOfFunc;
var x1,x2, // границы изменения аргумента функции
    y1, y2, //  границы изменения значения функции
    x,     // аргумент функции
    y,     // значение функции в точке х
    dx:real;  // приращение аргумента
    l,b:integer;  //левый нижний угол области  вывода графика
    w,h:integer; // ширина и высота области вывода графика
    mx,my:real; //  масштаб по осям x и y
    x0,y0:integer; // точка - начало координат
    n,sh,s:integer; // число еденичных меток на осях
    begin
      // Расчет области вывода графика
      l:=20;
      b:=Form1.ClientHeight-20; // y-координата левого нижнего угла
      h:=Form1.ClientHeight-40; // высота
      w:=Form1.ClientHeight-40; // ширина
      x1:=-10; // нижняя граница диапазона аргумента
      x2:=10;  // верхняя граница диапазона аргумента
      dx:=0.01; // шаг аргумента
      // Вычисление максимального и минимального значения
      // функции на отрезке [x1,x2]
      y1:=f(x1); // переменная для минимума
      y2:=f(x2); // переменная для максимума
      x:=x1;
      repeat
        y:=f(x);
          if y<y1 then y1:=y;
          if y>y2 then y2:=y;
          x:=x+dx;
      until (x>=x2);
      // Вычисление масштаба
      my:=h/abs(y2-y1); // масштаб по оси Y
      mx:=w/abs(x2-x1); // масштаб по оси X
      x0:=l+abs(Round(x1*mx)); // положение начала
      y0:=b-abs(Round(y1*my)); // координат
      // Рисование и разметка осей координат
      with Form1.Canvas do
      begin
        MoveTo(x0,b); LineTo(x0,b-h); // рисуем ось Y
        MoveTo(l,y0); LineTo(l+w,y0); // рисуем ось X
        // Разметка оси OY
        TextOut(x0+5,b-h,FloatToStrF(y2,ffGeneral,6,3)); // нанесем
         //на ось Y MAX
         TextOut(x0+5,b,FloatToStrF(y1,ffGeneral,6,3)); // и min
         //  значение функции
         n:=Round(Form1.ClientHeight/40); // количество меток
         if (y2-y1)<100 then // подбираем шаг расстановки меток
         // в зависимости от диапазона
         //  изменение значение функции
         begin
           sh:=round((y2-y1)/n);
           s:=round(y1);
         end
            else
            begin
              sh:=(Round((y2-y1)/n) div 10)*10; // выделим только десятки
              s:=(Round(y1) div 10)*10
            end;
            repeat
                   MoveTo(Round(x0-2), Round(y0+s*my)); // рисуем риски
                   // меток
                   LineTo(Round(x0+2), Round(y0+S*my)); // и приставляем числа
                   TextOut(x0-30,Round(y0-5+s*my),
                   FloatToStrF(-l*S,ffGeneral,6,3));
                   S:=s+sh;

            until (s>y2);
            // Разметка оси OX
            n:=Round(w/40);
            if (x2-x1)<100
            then // аналогично для оси X
            begin
              sh:=Round((x2-x1)/n);
              s:=Round(x1)
            end
      else
      begin
        sh:=(Round((x2-x1)/n) div 10)*10;
         s:=(Round(x1) div 10)*10
      end;
      repeat
        MoveTo(Round(x0+s*mx),y0-2);
        LineTo(Round(x0+s*mx),y0+2);
        TextOut(Round(x0-5+s*mx),y0+15,
        FloatToStrF(S,ffGeneral,6,3));
        S:=S+sh;
      until (s>x2);
      // ПОСТРОЕНИЕ ГРАФИКА ФУНКЦИИ
      x:=x1;
      repeat
        y:=f(x);
      // Закрашенивание точки графической сетки красным цветом
        Pixels [x0+Round(x*mx),y0-Round(y*my)]:=clRed;
        x:=x+dx;
      until (x>=x2);
      end;
    end;
    //  Запцск построения графика с открытием формы
    Procedure   TForm1FormPaint(Sender: TObject);
    begin
      GrofFunc;
    end;
    // Перерисоувывание графика с изменением размера формы
    Procedure TForm1FormResize(Sender: TObject);
    begin
      // очистить форму
      Form1.Canvas.FillRect(Rect(0,0,ClientWidth,ClientHeight));
      // построить график
      GrofFunc;
    end;
    end.

enter image description here



Solution 1:[1]

When you want to assign an event handler for a form, e.g. OnPaint(), do as follows:

  1. Make sure you have the form selected in the Object Inspector
  2. Select the Events tab
  3. Locate the OnPaint event
  4. Double-click in the right side column

The IDE will create the OnPaint event handler with the nasme FormPaint()

  TForm1 = class(TForm)
    ...
    procedure FormPaint(Sender: TObject);

, store the link to this event handler in the .dfm of the form

and write a skeleton implementation

procedure TForm1.FormPaint(Sender: TObject);
begin

end;

Then you just fill in the GrofFunc; call

Do the same for the OnResize event. In the implementation you don't need to refer to the form, so just write:

  Canvas.FillRect(Rect(0,0,ClientWidth,ClientHeight));
  GrofFunc;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1