SWindow BringToFront Broken on Win32

The BringToFront, forced using BringToFront(true) or otherwise, doesn’t seem to have any effect on Windows. I’ve gotten the list of all the top-level windows of the application and called BringToFront(true) to force the windows to the top and there doesn’t seem to be any effect. The keyboard and mouse are not captured for input and neither is the window brought to the fore and if minimized it stays that way.

Is this a bug? Is there a different expected way to bring the main game window to the front and focused capturing input using the C++ API at all?

Thanks!

edit: also, wanted to add that this was tested on Windows 8.1, I haven’t tried or XP to confirm. This is a problem both running in the editor, standalone from the editor and packaged and running separately.

Hi ,

You mentioned that this issue is happening for you on Win32. Do you see the same results on Win64?

Actually by win32 I meant windows, as in the win32 API. The build is actually an x64 build. I can try x32 but I expect it will be the same. I’ll post the relevant bit of code I expected would do something, but essentially it was get all top level windows and call beingToFrojt with the force parameter set to true. It doesn’t work whether the parameter is true or false. Windows stay minimized or even if visible don’t capture focus at all.

Ah, I thought you were referring to the Solution Platform setting in Visual Studio. Sorry about the confusion.

Could you provide the code where you are trying to get BringToFront to work?

Sorry for the delay. I’ve tried many things with native handles as well, below is just the bit using Unreal functionality that I would have hoped worked. To test, I had an actor that on Tick would call the below code. So to test you would just just put this in an actor, alt-tab from the window and it should switch back, it doesn’t in my case nor does it recapture input.

FSlateApplication::Get().SetFocusToGameViewport();
auto windows = FSlateApplication::Get().GetInteractiveTopLevelWindows();
for (auto w : windows) {
	w->GetNativeWindow()->BringToFront(true);
}
FSlateApplication::Get().SetFocusToGameViewport();
FSlateApplication::Get().SetKeyboardFocus(FSlateApplication::Get().GetGameViewport());

Hi ,

I just wanted to clarify something to make sure we are investigating this issue correctly. Are you wanting to use BringToFront to put the focus for the Windows OS back into your game window when you move the focus to another application (such as a Chrome browser window), or are you referring to Slate windows that you have created within your game UI?

The former. Basically my app switches away to the desktop or other apps and then has a need to be able to bring itself back in focus and capture input once more. I can switch away easily in C++ but I haven’t yet found a way to get back in. So ideally BringToFront or SetFocusToGameViewport would cover my case. Thanks again with this!

Hi ,

I apologize for not responding to this post sooner. Are you still experiencing trouble with this issue? I will mark this post as resolved for tracking purposes, but if you still need any assistance, please don’t hesitate to respond and reopen it.