How to bring a foreign window to top?

G

Guest

Hi,

from a dotnet winform application I start a process which is a Windows
application. I want the window to stay visible even if the user clicks on the
winform window.

I tried to call BringWindowToTop:

[DllImport("user32.dll")]
public static extern Boolean BringWindowToTop(IntPtr hWnd);

IntPtr hWnd=process.MainWindowHandle;
bool bResult=de.itools.util.Win32.ApiCalls.BringWindowToTop(hWnd);

where process is the System.Diagnostics.Process which was startet before. I
get true as result, but the window does not come to foreground.

As this doesn't work I tried with other window handles:

IntPtr hWnd=process.Handle;

or

IntPtr hWnd=de.itools.util.Win32.ApiCalls.GetTopWindow(
process.MainWindowHandle);

or

IntPtr hWnd=de.itools.util.Win32.ApiCalls.GetTopWindow(
process.Handle);

but with no success. It seems all these calls dont affect the window at all.

TIA
Frank
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Frank,

You should probably post a compilable sample source code that we can run and
test against.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top