Unfortunately I have been unable to get the scrollbar positions using the windows API to set the layer position that way, but I had some success by using the VisibleBitmapRect.
procedure TForm1.ImageEnView1ViewChange(Sender: TObject; Change: Integer);
var
iRect: TRect;
ix: Integer;
iy: Integer;
begin
{ If there is a magnify layer }
if ImageEnView1.LayersCount > 1 then
if (ImageEnView1.Layers[1].Magnify.Enabled) then
begin
{ Get the rect of the visiblebitmap }
iRect := ImageEnView1.VisibleBitmapRect;
ix := iRect.Left;
iy := iRect.Top;
ImageEnView1.Layers[1].PosX := ix;
ImageEnView1.Layers[1].PosY := iy;
end;
end;
This should keep the magnify layer visible at the top left of the visible bitmap. It seems to work when zooming in but not when zooming out. I have no idea what the problem is.
Update
I finally figured it out. This keeps the magnify layer visible at all times at the top left edge of the visible bitmap regardless of the zoom level when zooming in or out.
procedure TForm1.ImageEnView1ViewChange(Sender: TObject; Change: Integer);
var
iRect: TRect;
ix: Integer;
iy: Integer;
begin
{ If there is a magnify layer }
if ImageEnView1.LayersCount > 1 then
if (ImageEnView1.Layers[1].Magnify.Enabled) then
begin
{ Get the rect of the visiblebitmap }
iRect := ImageEnView1.VisibleBitmapRect;
{ Set the layers coordinates }
ix := iRect.TopLeft.X + ImageEnView1.Layers[1].Width;
iy := iRect.TopLeft.Y + ImageEnView1.Layers[1].Height;
ImageEnView1.Layers[1].PosX := ix;
ImageEnView1.Layers[1].PosY := iy;
end;
end;
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development