Well that was easy. Luckily the bug was in my own code.
Here's the code that works:
procedure TFormMain.ImgViewMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer;
Layer: TCustomLayer);
begin
if (Button = mbLeft) then
begin
FPanning := True;
ImgView.Cursor := crSizeAll;
FStartPos := Point(X, Y);
end else
if (Button = mbMiddle) then
ImgView.Scale := 1;
end;
procedure TFormMain.ImgViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer);
begin
if (not FPanning) then
Exit;
var NewPos := Point(X, Y);
var Delta := FStartPos - NewPos;
FStartPos := NewPos;
if (Delta.X <> 0) or (Delta.Y <> 0) then
ImgView.Scroll(Delta.X, Delta.Y);
end;