question

LingSteven avatar image
0 Votes"
LingSteven asked ·

How to make edge browser show in front of my UWP app?

Hello,

This issue was related to UWP app and c# console application.

I made a simple server by using c# console application. And my UWP will run in full-screen mode and connect to it.

My console application will start a process to open the edge browser and do someting.

 Process.Start("http://.....");

As the UWP app was running in full-screen mode, the edge browser did not open in front of my UWP app. It just shows in the task bar. For making the edge show on top, I have to move my mouse to the bottom of the screen and click the edge in task bar.

I have tried the win32 APIs.

 [DllImport("user32.dll")]
 public static extern int ShowWindow(IntPtr hWnd, uint nCmdShow);
    
 public static extern bool SetForegroundWindow(IntPtr hWnd);
    
 public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

It only worked on the desktop computer. If I run my UWP and console application on laptop, it did not work. Any idea will be appreciated.

Thanks,
Steven



windows-uwpdotnet-csharpdotnet-console
· 6
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, You mentioned that your UWP app is connected to the console app. Can you elaborate on this? If you directly call Launcher.LaunchUriAsync() in a UWP application, will there still be a problem that the browser is not displayed in the foreground?

0 Votes 0 ·

Richard, thanks for your response. Actually, I have to start the edge in my console application code-behind. I mention UWP app because I think it's UWP's full-screen mode that's causing this problem, but I have no proof of that.

0 Votes 0 ·

If you get any useful information from the relevant team, please update here in time. Thanks.

0 Votes 0 ·

We can reproduce this issue and we are still troubleshooting on it.
One of the workaround for this issue is to make your app into the Max size in code behind instead of entering to full screen.
Thanks.

1 Vote 1 ·
Show more comments

We have been asking other engineers about this. There might be some time delay.

0 Votes 0 ·

1 Answer

AmyPeng1-MSFT avatar image
2 Votes"
AmyPeng1-MSFT answered ·

Hi XieSteven,

Based on this SetForegroundWindow API:

“An application cannot force a window to the foreground while the user is working with another window. Instead, Windows flashes the taskbar button of the window to notify the user.”

It should be not supported, but you said that this is working on Desktop, there might be some environmental variables that is affecting this behavior on your Desktop vs Laptop, however its recommended that the process that’s already on the foreground (the UWP application) should be the one that starts the new process (Edge) to avoid any issues down the line.

Thanks.


· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AmyPeng-MSFT Thank you so much :)

0 Votes 0 ·