managed code that will do the same as SetForegroundWindow
-
Does anyone know any way to set a process to be the foreground window in managed code, I have a Process object and need to set that process to be the front form. I was previously using the user32.dll function
SetForegroundWindow(p.MainWindowHandle);
, but I know have a requirement to use only managed code. Any ideas? -
Does anyone know any way to set a process to be the foreground window in managed code, I have a Process object and need to set that process to be the front form. I was previously using the user32.dll function
SetForegroundWindow(p.MainWindowHandle);
, but I know have a requirement to use only managed code. Any ideas?If the window is one in your application then you can call
Activate();
on the instance and it will activate the form. Why only managed code? Alot of the managed classes are just wrappers around the native stuff (or wrappers around managed wrappers!), calling API functions yourself is just the same so long as it is done correctly.Dave
Tip: Passing values between objects using events (C#) BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
If the window is one in your application then you can call
Activate();
on the instance and it will activate the form. Why only managed code? Alot of the managed classes are just wrappers around the native stuff (or wrappers around managed wrappers!), calling API functions yourself is just the same so long as it is done correctly.Dave
Tip: Passing values between objects using events (C#) BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)The process is not in my app, so the
Activate();
trick wont work for me. The managed code is a microsoft certification requirement. It's fine if there are 3rd party assemblies in my project that call unmanaged code, but there cannot be any in any of the code I've written.