I am calling Form.Show() on a certain Form and do some stuff afterwards which causes some updates on the Shown Form.
I want to move the this Window Form to another location with another Process during this time with SetWindowPos. Sadly the calling of SetWindowPos does exactly nothing. Probably because the is never idling?
Any Idea who to solve this Problem?
Thank you
Edit: some Code:
main.Show();
main.initBase(); //Takes 2-3 seconds
main.HideMainForm(); //Moves the form to (10000, 10000), to hide it (can't change that it's an old programm)
At the main.Shown
event i have a call to another program which than calls
SetWindowPos(pd.CurrentHandle, HWND_TOPMOST, r.X, r.Y, r.Width, r.Height, SetWindowPosFlags.DoNotChangeOwnerZOrder);
where r is the rectangle of the selected Display
I tried
EventHandler ev = new EventHandler((s, e) =>
{
main.Close();
ev = new EventHandler((s2, e2) => { });
});
main.Shown += ev;
main.ShowDialog();
main.Show();
which works fine but is just ugly code and i am trying to find a better solution.