0

How can I animate two windows at the same time? I tried:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern bool AnimateWindow(IntPtr hwnd, int time, int flags);
...

AnimateWindow(panel1.Handle, speed, AW_SLIDE | AW_HOR_Top);
AnimateWindow(panel2.Handle, speed, AW_SLIDE | AW_HOR_Top);

But panel2 will not animate until panel1 finished its animation.

I must use the threading .. but i can't even if i used invoke .. also it runs the 2nd animation after the 1st

so how can i do it ?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
MIM
  • 9
  • 3
  • 3
    From the [AnimateWindow](http://msdn.microsoft.com/en-us/library/windows/desktop/ms632669(v=vs.85).aspx) msdn: `If the thread does not own the window. Note that, in this case, AnimateWindow fails but GetLastError returns ERROR_SUCCESS.` – matthewr Jun 21 '12 at 21:37

1 Answers1

1

If both windows were created by the same thread, then the AnimateWindow function will run on that thread. According to the MSDN documentation:

The function will fail in the following situations:

  • If the thread does not own the window. Note that, in this case, AnimateWindow fails but GetLastError returns ERROR_SUCCESS.

There is no way around this other than creating the second window on a separate thread. Additionally, you will have to call the AnimateWindow function from the thread that each window was created on.

Community
  • 1
  • 1
Joel Lucsy
  • 8,520
  • 1
  • 29
  • 35