You can restrict the position of a layer to a specified XY value in the LayerNotify event:
procedure TForm1.ImageEnView1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
begin
{ Show the layer position when moving }
if (event = ielMoving) then
StatusBar1.Panels[6].Text := 'Layer Pos: ' + IntToStr(ImageEnView1.Layers[layer].PosX) + ' x '
+
IntToStr(ImageEnView1.Layers[layer].PosY);
{ Do not allow layer 1 to be moved to a point less than PosX=30 and PosY=60 }
if (event = ielMoved) and (Layer = 1) then
begin
{ if PosX < 20 show message }
if (ImageEnView1.Layers[layer].PosX < 30) then
begin
ShowMessage('Can not move the layer');
{ Reset the layer PosX to acceptable position }
ImageEnView1.Layers[layer].PosX := 31;
ImageEnView1.Update;
StatusBar1.Panels[6].Text := 'Layer Pos: ' + IntToStr(ImageEnView1.Layers[layer].PosX) + ' x '
+
IntToStr(ImageEnView1.Layers[layer].PosY);
exit;
end;
{ if PosY < 60 show message }
if (ImageEnView1.Layers[layer].PosY < 60) then
begin
ShowMessage('Can not move the layer');
{ Reset the layer PosY to acceptable position }
ImageEnView1.Layers[layer].PosY := 61;
ImageEnView1.Update;
StatusBar1.Panels[6].Text := 'Layer Pos: ' + IntToStr(ImageEnView1.Layers[layer].PosX) + ' x '
+
IntToStr(ImageEnView1.Layers[layer].PosY);
exit;
end;
end;
end;
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html