(Windows) Launch/Close Programs With Fullscreen

General FreeBASIC programming questions.
Post Reply
Username
Posts: 30
Joined: Jun 22, 2020 5:56

(Windows) Launch/Close Programs With Fullscreen

Post by Username »

Hey.
I've been wondering:
When the CHAIN command is used to launch another program, and then the program closes, when a fullscreen mode is used at least for the original program, the program won't do anything until the user switches it back to active again, such as by clicking it in the taskbar.
Is there a simple way to resume program execution after a called program quits, with no user interaction?
Thank you.
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: (Windows) Launch/Close Programs With Fullscreen

Post by fxm »

Workaround on Windows:
fxm wrote: Aug 20, 2014 21:06 The only and best solution I've found to force a window to the foreground with the focus, whatever the starting configuration, is to run the 5 following commands in this order:
- Hide (not absolutely necessary, just to reduce a little the window flashing)
- Minimize
- Restore
- Foreground
- Focus

Test program:

Code: Select all

#INCLUDE "windows.bi"
#INCLUDE "fbgfx.bi"

DIM HandleWindow AS HWND

SCREEN 12

PRINT
PRINT " You have 5 seconds:"
PRINT "   - to put the graphic window in the background,"
PRINT "   - or to minimize the graphic window."
SLEEP 5000

SCREENCONTROL(FB.GET_WINDOW_HANDLE, CAST(INTEGER, HandleWindow))
ShowWindow(HandleWindow, SW_HIDE) 'Hide
ShowWindow(HandleWindow, SW_MINIMIZE) 'Minimize
ShowWindow(HandleWindow, SW_RESTORE) 'Restore
SetForegroundWindow(HandleWindow) 'Foreground
SetFocus(HandleWindow) 'Focus

PRINT
PRINT " The window is back in the foreground with the focus."

SLEEP
Username
Posts: 30
Joined: Jun 22, 2020 5:56

Re: (Windows) Launch/Close Programs With Fullscreen

Post by Username »

fxm wrote: Jul 15, 2022 4:49 Workaround on Windows:
fxm wrote: Aug 20, 2014 21:06 The only and best solution I've found to force a window to the foreground with the focus, whatever the starting configuration, is to run the 5 following commands in this order:
- Hide (not absolutely necessary, just to reduce a little the window flashing)
- Minimize
- Restore
- Foreground
- Focus

Test program:

Code: Select all

#INCLUDE "windows.bi"
#INCLUDE "fbgfx.bi"

DIM HandleWindow AS HWND

SCREEN 12

PRINT
PRINT " You have 5 seconds:"
PRINT "   - to put the graphic window in the background,"
PRINT "   - or to minimize the graphic window."
SLEEP 5000

SCREENCONTROL(FB.GET_WINDOW_HANDLE, CAST(INTEGER, HandleWindow))
ShowWindow(HandleWindow, SW_HIDE) 'Hide
ShowWindow(HandleWindow, SW_MINIMIZE) 'Minimize
ShowWindow(HandleWindow, SW_RESTORE) 'Restore
SetForegroundWindow(HandleWindow) 'Foreground
SetFocus(HandleWindow) 'Focus

PRINT
PRINT " The window is back in the foreground with the focus."

SLEEP
Thank you!
I will try that (at some point I'll get around to it).
Post Reply