1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| procedure TForm1.TBChange(Sender: TObject);
var
Rgn1, Rgn2 :hRgn;
begin
r.Top := trunc(y * TB.Position / 100);
r.Left := trunc(x * TB.Position / 100);
r.Right := trunc(xx * TB.Position / 100);
r.Bottom := trunc(yy * TB.Position / 100);
Bckg.Canvas.CopyRect(r, Image1.Picture.Bitmap.Canvas, i);
//Région PaintBox complet
with i do Rgn1 := CreateRectRgn(Left, Top, Right, Bottom);
//Région Image
with r do Rgn2 := CreateRectRgn(Left, Top, Right, Bottom);
//Supprime la région Image (Rgn2) de celle du PaintBox (Rgn1)
//Le résultat est placé dans Rgn1. Rgn1 devient un polygone
CombineRgn(Rgn1, Rgn1, Rgn2, RGN_XOR);
FillRgn(Bckg.Canvas.Handle, Rgn1, Canvas.Brush.Handle);
//Décommente ces deux ligne pour "voir" la région
// Bckg.Canvas.Brush.Color := clRed;
// FrameRgn(Bckg.Canvas.Handle, Rgn1, Bckg.Canvas.Brush.Handle, 1, 1);
DeleteObject(Rgn1);
DeleteObject(Rgn2);
end; |
Partager