{
Here goes one approach of drawing a lasso
rectangle with Delphi
}
1. In the OnMouseDown event for the form
that you are 'lasso-ing' controls on:
bMarquee := True;
ptOrigin := Point(X,Y);
ptMove := Point(X,Y);
Pen.Color := clBlack;
Pen.Width := 1;
Pen.Style := psDash;
Brush.Style := bsClear;
DrawMarquee(ptOrigin, ptMove, pmNotXor );
2. In the OnMouseMove event for the form...
if bMarquee = True then begin
DrawMarquee(ptOrigin, ptMove, pmNotXor);
DrawMarquee(ptOrigin, Point(X,Y), pmNotXor);
ptMove := Point(X, Y);
Canvas.Pen.Mode := pmCopy;
end;
3. In the OnMouseUp event for the form...
if bMarquee = True then begin
bMarquee := False;
DrawMarquee(ptOrigin, Point(X,Y), pmNotXor);
ptMove := Point(X,Y);
end;
4. The DrawMarquee procedure...
procedure myForm.DrawMarquee
(mStart, mStop : TPoint; AMode : TPenMode);
begin
Canvas.Pen.Mode := AMode;
Canvas.Rectangle(mStart.X,mStart.Y,mStop.X,mStop.Y);
end;