title: Zoom canvas area in Delphi
body: <p>I making something that looks like Paint in Delphi. I found how to make zoom function:</p>
  
  <pre><code>procedure SetCanvasZoomFactor(Canvas: TCanvas; AZoomFactor: Integer);
  var
    i: Integer;
  begin
    if AZoomFactor = 100 then
      SetMapMode(Canvas.Handle, MM_TEXT)
    else
    begin
      SetMapMode(Canvas.Handle, MM_ISOTROPIC);
      SetWindowExtEx(Canvas.Handle, AZoomFactor, AZoomFactor, nil);
      SetViewportExtEx(Canvas.Handle, 100, 100, nil);
    end;
  end;
  
  
  
  procedure TMainForm.btnZoomPlusClick(Sender: TObject);
  var
    bitmap: TBitmap;
  begin 
  
    bitmap := TBitmap.Create;
    if(zoomVal &lt; 1000) then
        zoomVal:=zoomVal+zoomConst; //zoomVal = 100 by default; zoomConst = 150;
    try
      bitmap.Assign(MainForm.imgMain.Picture.Bitmap);
      SetCanvasZoomFactor(bitmap.Canvas, zoomVal);
      Canvas.Draw(MainForm.imgMain.Left,MainForm.imgMain.Top, bitmap); 
    finally
      bitmap.Free
    end;
  end;
  </code></pre>
  
  <p>But, the problem is - it zooms only upper left region of image.</p>
  
  <p>Example
  before zoom:
  <img src="https://i.stack.imgur.com/Ehfl2.png" alt="enter image description here">
  after zoom:
  <img src="https://i.stack.imgur.com/FlvVS.png" alt="enter image description here"></p>
  
  <p>I want to be able to move through all picture area, even after zoom. How can I make this?</p>