Selecting multiple objects

Please discuss general Delphi programming topics here.

Selecting multiple objects

Postby mdomeyko2 » January 9th, 2008, 8:55 pm

In run time, how can I draw that box line for selecting multiple objects for moving/resizing, etc..

Does anybody have that code? need urgent :?
Canguro
Miami, FL
mdomeyko2
Active Member
Active Member
 
Posts: 11
Joined: September 18th, 2006, 10:06 pm

Postby john123 » January 15th, 2008, 7:49 am

Hi, you can use follow Code:
Code: Select all
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    Flag: Boolean;
    StartPoint, PrvPoint: TPoint;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Flag:= False;
  Canvas.Brush.Style:= bsClear;
  Canvas.Pen.Mode:= pmNotXor;
  Canvas.Pen.Style:= psDot;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  If Button = mbLeft then
  begin
    Flag:= True;
    StartPoint.X:= X;
    StartPoint.Y:= Y;
    PrvPoint.X:= X;
    PrvPoint.Y:= Y;
  end;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  If Flag then
  begin
    Canvas.Rectangle(StartPoint.X, StartPoint.Y, PrvPoint.X, PrvPoint.Y);
    Canvas.Rectangle(StartPoint.X, StartPoint.Y, X, Y);
    PrvPoint.X:= X;
    PrvPoint.Y:= Y;
  end;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = mbLeft then
    Flag:= False;
end;

end.
john123
Active Member
Active Member
 
Posts: 15
Joined: November 7th, 2007, 10:43 am

Selecting multiple objects

Postby mdomeyko2 » January 15th, 2008, 6:27 pm

Thanks Kambiz, your the best!

Now my headache is trying to select a group of objects, move them around, align them, change their properties (size, color,...), put a text in caption, etc...
Do you have anything like that?

Canguro
Canguro
Miami, FL
mdomeyko2
Active Member
Active Member
 
Posts: 11
Joined: September 18th, 2006, 10:06 pm

Postby john123 » January 16th, 2008, 6:59 pm

Did you mean: John123 or Kambiz?
john123
Active Member
Active Member
 
Posts: 15
Joined: November 7th, 2007, 10:43 am

Postby Kambiz » January 16th, 2008, 10:26 pm

john123, seems mdomeyko2 was so happy about your code that didn't look who has provided it. :lol:
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2424
Joined: March 7th, 2003, 7:10 pm

Postby mdomeyko2 » January 18th, 2008, 6:49 pm

Sorry John123. I received the email from Lambiz and in fact, I was very hoping happy, so I assumed wrong.. but ALL you guys are great!
Canguro
Miami, FL
mdomeyko2
Active Member
Active Member
 
Posts: 11
Joined: September 18th, 2006, 10:06 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron