How to put screen to foreground

New to FreeBASIC? Post your questions here.
Post Reply
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

How to put screen to foreground

Post by Tourist Trap »

Hi,

I noticed that when compiled to gui (-s gui) the fb screen can go to background (in particular at avsecond screenres call).
Can we give the focus back to the fb screen and put it back to foreground?

This issue doesn't really appear when we compile to console (even with subsequent screenres calls).

Thanks folk!
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: How to put screen to foreground

Post by grindstone »

Which OS / IDE ?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: How to put screen to foreground

Post by D.J.Peters »

Do you end the first call with screen 0 before you call screenres a second time ?
Do you tried GFX_ALWAYS_ON_TOP with screenres ?

Joshy
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: How to put screen to foreground

Post by Tourist Trap »

grindstone wrote:Which OS / IDE ?
Win10 64.
I tried both on fbEdit and fbIde. On FbIde, it's a quick run so the cmd window is still here despite the -s gui option. In both cases, the second call for a screenres makes the window go back relative to the editor for FbEdit, and back the cmd window for FbIde.
D.J.Peters wrote:Do you end the first call with screen 0 before you call screenres a second time ?
Do you tried GFX_ALWAYS_ON_TOP with screenres ?

Joshy
A screen 0 does nothing. However Always on Top is working. This can make a workaround, thanks I forgot this one :)
But I still wonder, is there a way to grant our screen the focus via a freebasic poke?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: How to put screen to foreground

Post by D.J.Peters »

The window in foreground has the focus so GFX_ALWAYS_ON_TOP should do the trick.

If your app or game lost the focus you can record this event with ScreenEvent()
https://www.freebasic.net/wiki/wikka.ph ... creenevent
the events are : EVENT_WINDOW_LOST_FOCUS and EVENT_WINDOW_GOT_FOCUS

Today I enter the love letter competition and use EVENT_WINDOW_LOST_FOCUS also.

If I get this event the game main loop and sound output are paused.

Joshy
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: How to put screen to foreground

Post by Tourist Trap »

D.J.Peters wrote:
Today I enter the love letter competition and use EVENT_WINDOW_LOST_FOCUS also.

If I get this event the game main loop and sound output are paused.

Joshy
Thanks for sharing, this is a nice idea.
Post Reply