Title: Moving two form at the same time.
Question: How to move two forms at the same time, that is to say, simultaneously?
Answer:
Well,
We will carry out a work that perhaps some judicious ones don't like
it somewhere around but it can be solved in the following way.
A called message exists in Windows WM_WINDOWPOSCHANGING that is the
one that helps us in this case. Because anything, we declare a method
with this message and we control to the same one, it would be something as:
...
public
OldTop, OldLeft: Integer;
procedure MoveWindow(var m: TWMWindowPosChanged);
message WM_WindowPosChanging;
end;
...
implementation
...
procedure TForm1.MoveWindow(var m: TWMWindowPosChanged);
var
DTop, DLeft: Integer;
begin
...
// well and here inside of you put the relationship of like you
// want him to move.
// an example of this moving them in the same sense can be...
if (Form2 = nil) or (not Form2.Visible) then Exit;
// this line is to avoid the error of calling them when the forms
// are creating or when they are not visible...
DTop := Top - OldTop;
DLeft := Left - OldLeft;
if (DTop 0) or (DLeft 0) then
begin
Form2.Top := Form2.Top + DTop;
Form2.Left := Form2.Left + DLeft;
end;
OldTop := Top;
OldLeft := Left;
...
end;