Guest User

Untitled

a guest
Aug 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. While Animating windows forms to slide in, Form Appearing at wrong location
  2. [DllImport("user32")]
  3. static extern bool AnimateWindow(IntPtr hwnd, int time, int flags);
  4.  
  5. //Set the Location negative values are being returned when my dialog appears
  6. this.Location = new Point(LocationMainX + WidthOfMain, locationMainy + 10);
  7.  
  8. //Animate form
  9. AnimateWindow(this.Handle, 750, AW_SLIDE | AW_HOR_POSITIVE);
  10.  
  11. AddForm form = new AddForm (this.DesktopLocation)
  12. form.ShowDialog(); //I have also noticed doing form.Show(); messes with the position of dialog
  13.  
  14. AddForm form = new AddForm (this.Parent.DesktopLocation)
  15. form.ShowDialog();
  16.  
  17. using System.Runtime.InteropServices;
  18.  
  19. [DllImport("user32.dll")]
  20. [return: MarshalAs(UnmanagedType.Bool)]
  21. static extern bool GetWindowRect(HandleRef hWnd, out RECT lpRect);
  22.  
  23. [StructLayout(LayoutKind.Sequential)]
  24. public struct RECT
  25. {
  26. public int Left;
  27. public int Top;
  28. public int Right;
  29. public int Bottom;
  30. }
  31.  
  32. RECT fromRECT;
  33. GetWindowRect(new HandleRef(this, button1.Handle), out fromRECT);
  34. form.Location = new Point(fromRECT.Left + (fromRECT.Right - fromRECT.Left), fromRECT.Top);
  35. form.Show();
Add Comment
Please, Sign In to add comment