I'm not sure you should lock both forms.  If you move form1 then form2 
moves which moves form1 ...

Here is the code so that form2 is moved when form1 moves.  Form1 has only a 
button.  Form2 is just a form.  Both are auto created.

Hope it helps

Garth

unit Unit1;

interface

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

type
   TForm1 = class(TForm)
     Button1: TButton;
     procedure Button1Click(Sender: TObject);
   private
     procedure Moving(var AMsg: TMessage); message WM_MOVING;
     procedure Move(var AMsg: TMessage); message WM_MOVE;
     procedure KeepStation(AForm: TForm);
     { Private declarations }
   public
     { Public declarations }
   end;

var
   Form1: TForm1;

implementation

{$R *.DFM}

uses Unit2;

procedure TForm1.Button1Click(Sender: TObject);
begin
   Form2.Hide;
   KeepStation(Form2);
   Form2.Show;
end;

procedure TForm1.KeepStation(AForm: TForm);
begin
   AForm.Left := Form1.Left + Form1.Width;
   AForm.Top  := Form1.Top  + Form1.Height;
end;

procedure TForm1.Move(var AMsg: TMessage);
begin
   if assigned(Form2) then
   begin
     KeepStation(Form2);
   end;
end;

procedure TForm1.Moving(var AMsg: TMessage);
begin
// tried here but only fires once, try it and see.
//  if assigned(Form2) then
//  begin
//    KeepStation(Form2);
//  end;
end;

end.

>How do I lock two windowed forms together so if I move
>one of the forms on the screen the other one moves with it?
>
>_______________________________________________
>Delphi mailing list -> [email protected]
>http://www.elists.org/mailman/listinfo/delphi

Garth S. Wilcox
email addresses
[EMAIL PROTECTED]
[EMAIL PROTECTED]

web site: www.garthw.com 

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to