not every fullscreen application is a game and use Flipbuffers() many times per second. My (unfinished) fullscreen application use Flipbuffers() only seldom.
Here is my reduced code:
Code: Select all
; do not run this code
; this code is reduced to show the essential structure
; the main program open the main window, mouse click on a button call the
; procedure "Display_data()" as fullscreen application,
; the procedure "Screen_Handling()" should manage the Alt+Tab switching, but doesn't
; work correctly, because I use FlipBuffers() only seldom
Procedure Screen_Handling() ; check focus and redraw screen
; FlipBuffers() ; this would give a strongly flickering, but without this
; the reaction is after many seconds (after FlipBuffers())
If Not IsScreenActive() ; focus lost?
CloseScreen()
Window_State = GetWindowState(#Mainwindow)
SetWindowState(#Mainwindow, #PB_Window_Minimize) ;minimize main window
Repeat
Until WaitWindowEvent() = 0 ; without this loop the screen is immediately opened again
Repeat
Until WaitWindowEvent() = #PB_Event_ActivateWindow ; getting focus again ? Doesn't work.
SetWindowState(#Mainwindow, Window_State) ; resize main window
OpenScreen(Desktop_W, Desktop_H, Desktop_D, Title$)
ClearScreen(RGB(0,0,0))
If StartDrawing(ScreenOutput())
; ... here I redraw data on the fullscreen
StopDrawing()
FlipBuffers()
EndIf
EndIf
EndProcedure
Procedure Display_data()
If InitSprite_Result ; Direct X initialized?
If OpenScreen(Desktop_W, Desktop_H, Desktop_D, Title$) ; Fullscreen initialized ?
If InitKeyboard_Result ; Keyboard initialized ?
; ... here I prepare some variables
End_Flag = #False
Repeat
; Screen_Handling() ; this would doesn't work, but without this it works only
; after some seconds and it works only once
ClearScreen(RGB(0,0,0))
; ... here I modify variables for displaying data if no key pressed
; ... here I prepare data for displaying
If StartDrawing(ScreenOutput())
; ... here I draw data on the fullscreen
StopDrawing()
FlipBuffers()
EndIf
For i = 1 To max_time ; time and keyboard loop, max_time = seconds * 20
Screen_Handling() ; check focus and redraw screen
If Not Time_Mode
i = i - 1 ; endless time loop up to pressed key
EndIf
Delay(50) ; each second are 20 loopings
ExamineKeyboard()
; now many keys checked
If KeyboardReleased(...)
; modify variables for displaying data
Break
EndIf
If KeyboardPushed(...)
;modify variables for displaying data
Break
EndIf
If KeyboardPushed(#PB_Key_Escape)
End_Flag = #True
Break
EndIf
Next ; end of time and keyboard loop
Until End_Flag ; loops back for drawing new data on the fullscreen
CloseScreen()
EndProcedure ; ends fullscreen application and goes back to the main window
But from this results that Flipbuffers() is only seldom called. And Alt+Tab reacts only if the time_and_key_loop ends, after many seconds or minutes. PureBasic 4.41 blocks the Alt+Tab keys within the time_and_key_loop. Why? The system becomes processing time with Delay(50).
Sometimes Alt+Tab (for tabbing out) works only at the second time.
I have many many hours tested with Flipbuffers(), Isscreenactive(), ReleaseMouse(), waiting for focus comes back (doesn't work) or close screen and minimize main window or open a new minimized window to the task bar and if the window becomes activating then close the new window or resize the main window and open a new screen. All this doesn't work or works only once. I have found Djes solution and I will test it in the next days.
But the main problem remains: Isscreenactive() must be called after Flipbuffers(). And Flipbuffers() is called seldom. Therefore Isscreenactive() should not be bound to Flipbuffers(). If I write Flipbuffers() in the procedure "Screen_Handling()" then the Alt+Tab reaction time is very short but I have a strongly flickering on the fullscreen.
PureBasic is very difficult for beginners. Why PureBasic doesn't handle the Alt+Tab switching?
Greetings.
I use PB 4.41 with Windows XP SP 3.