I want to select multiple objects on the canvas at runtime ..
Like CorelDraw for instance ...
Thanks!
Rkr
Hope this helps
Nigel Stratton
Fairplay
rkr...@pacbell.net wrote in article <32DDC2...@pacbell.net>...
>Does anyone know how to draw a box on the canvas when the user clicks
>the left mouse button and drags to a new location.
>
>I want to select multiple objects on the canvas at runtime ..
Here's the method I use to Rubber Band on and image control. The same
works for a form.
Declare some private integers to store the XY positions whilst drawing.
private
{ Private declarations }
NoOfPoints, X1,Y1,X2,Y2 : Integer;
Drawing : Boolean;
On the Mouse down event set the drawing mode etc.
procedure TMain.imgPicMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with imgPic do
begin
Canvas.Pen.Mode := pmXOr;
Canvas.Pen.Style := psDot;
X1 := X; Y1 := Y; X2 := X; Y2 := Y;
end;
end;
procedure TMain.imgPicMouseMove(Sender: TObject; Shift: TShiftState; X, Y:
Integer);
begin
StatusBar.Caption := intToStr(X) + ' : ' + intToStr(Y);
if ssLeft in Shift then
begin
with imgPic do
begin
Drawing := True;
{clear the last line first}
Canvas.PolyLine([Point(X1,Y1),Point(X2,Y1),Point(X2,Y2)]);
Canvas.PolyLine([Point(X1,Y1),Point(X1,Y2),Point(X2,Y2)]);
X2 := X; Y2 := Y;
{now draw the new line}
Canvas.PolyLine([Point(X1,Y1),Point(X2,Y1),Point(X2,Y2)]);
Canvas.PolyLine([Point(X1,Y1),Point(X1,Y2),Point(X2,Y2)]);
end;
end
else
Drawing := False;
end;
procedure TMain.imgPicMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Drawing = True then
Do something with the selected region ......
end;
Regards
Kevin
*************************************
* Kevin Read
* E-Mail: ke...@fbs.com.au
* http://www.fbs.com.au
*************************************