unit Unit2;
interface
uses
Unit1;
type
TForm2 =
class(TForm)
Panel1: TPanel;
CheckBox1: TCheckBox;
ScrollBox1: TScrollBox;
Image1: TImage;
PaintBox1: TPaintBox;
procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
FSelecting: Boolean;
FSelection: TRect;
pos1, pos2, pos3, pos4: Integer;
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if CheckBox1.Checked
then
begin
FSelection.Left := X;
FSelection.Top := Y;
FSelecting := true;
end;
end;
procedure TForm2.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if FSelecting
then
begin
FSelection.Right := X;
FSelection.Bottom := Y;
pbRec.Invalidate;
end;
end;
procedure TForm2.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if CheckBox1.Checked
then
begin
FSelecting := false;
FSelection.Right := X;
FSelection.Bottom := Y;
PaintBox1.Invalidate;
FSelection.NormalizeRect;
if FSelection.IsEmpty
then
begin
// None selection was made on PaintBox
end
else
begin
pos1 := FSelection.Left;
pos2 := FSelection.Top;
pos3 := X;
pos4 := Y;
end;
end;
end;
procedure TForm2.PaintBox1Paint(Sender: TObject);
begin
if CheckBox1.Checked
then
begin
PaintBox1.Canvas.Brush.Style := bsClear;
PaintBox1.Canvas.Pen.Style := psSolid;
PaintBox1.Canvas.Pen.Color := clRed;
PaintBox1.Canvas.Rectangle(FSelection);
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
Socket: TCustomWinSocket;
begin
Socket := TCustomWinSocket(Form1.LV1.Selected.SubItems.Objects[0]);
if CheckBox1.Checked
then
begin
Socket.SendText(intToStr(pos1) + '
;' + intToStr(pos2) + '
;' +
intToStr(pos3) + '
;' + intToStr(pos4));
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
Form3 := TForm3.Create(Self);
Form3.Show;
end;