Move two Forms simultaneously

  • Thread starter Thread starter gourmete
  • Start date Start date
G

gourmete

HI!

My first post, so Hello there!
I´m trying to develop an apllication with docked forms, like in
Winamp. If a child forms is docked to the parent form it should move
and resize like the parent form does.

I´ll give you an simple example of how I tried to archive this:

Form parent = new Form();
parent.TopMost = true;
Form child = new Fom();

parent.Move += new EventHandler(parent_move);

void parent_move(object sender, EventArgs e)
{
child.Bounds = parent .Bounds;
}


This example is not very usefull, because the parent form will
completly cover the child, but it shows my problem: The child form
moves slowlyer. Moving the parent form will cause the child form to
move, but with a delay of time. I want them to move as if they where
ONE form!!!

I was seraching for days now, tried serveral Win32 Api calls regarding
moving but I didn´t get it!

Can anyone help me?
 
gourmete said:
I was seraching for days now, tried serveral Win32 Api calls regarding
moving but I didn´t get it!

Can anyone help me?

This seems to work ok

private const int WM_MOVE = 0x3;
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if(m.Msg == WM_MOVE)
{
otherForm.Location = new Point(this.Right, this.Top);
}
}
 
Back
Top