Get a window of other application topmost
-
Hi, I want to start a new application from my C# program.(this part works ;) ) This new window should then get maximized and topmost. I tried it with WinAPI calls but I was not successful. Is there a way to do this ? Thanks in advance, outerlimit
-
Hi, I want to start a new application from my C# program.(this part works ;) ) This new window should then get maximized and topmost. I tried it with WinAPI calls but I was not successful. Is there a way to do this ? Thanks in advance, outerlimit
-
Hi, I want to start a new application from my C# program.(this part works ;) ) This new window should then get maximized and topmost. I tried it with WinAPI calls but I was not successful. Is there a way to do this ? Thanks in advance, outerlimit
You should post your code so we can see what you're trying
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi, I want to start a new application from my C# program.(this part works ;) ) This new window should then get maximized and topmost. I tried it with WinAPI calls but I was not successful. Is there a way to do this ? Thanks in advance, outerlimit
Hello, You have to use the MainWindowHandle property of the process in combination with BringWindowtoTop method of user32.dll.
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int BringWindowToTop(IntPtr hwnd);public IntPtr HWND_TOPMOST =(IntPtr)(-1);
public IntPtr HWND_NOTOPMOST =(IntPtr)(-2);//Your method System.Diagnostics.ProcessStartInfo psi; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized; psi.FileName = "???.exe"; using(System.Diagnostics.Process process = new System.Diagnostics.Process()) { process.Start(psi); process.WaitForInputIdle(); BringWindowToTop(process.Handle); }
Hope it helps! All the best, Martin