GetActiveWindow() for fullscreen 3D mode.

Blitz3D Forums/Blitz3D Bug Reports/GetActiveWindow() for fullscreen 3D mode.

Here is a little example, so you can test this bug:

Graphics3D 800,600,32,1; <- try to switch to window/fullscreen mode 

hWND=SystemProperty("AppHWND")

GlobalTimer=vdCreateTimer()



While Not KeyDown(1)

ActiveWindow=api_GetActiveWindow()
If ActiveWindow<>hWND 
	MainLoopPaused=True
	vdSetAllTimersPause(True)
	Delay 1
Else
	If OldActiveWindow<>hWND
		vdUpdateTimers()

		vdSetAllTimersPause(False)
		MainLoopPaused=False
	EndIf
EndIf
OldActiveWindow=ActiveWindow

	If MainLoopPaused=False
		;Main loop goes here
		vdUpdateTimers()
		UpdateWorld()
		RenderWorld()
		Cls
		Text 10,10,vdGetTimer(GlobalTimer)

		Flip
	EndIf			
Wend

End









Const cTimeTimer=1

Type TimerT
    Field TimerID
    Field TimerTime
    Field TimerFrame
    Field StartTime
    Field CurTime
    Field Paused
    
End Type

Function vdCreateTimer()
	
	this.TimerT		= New TimerT           
	this\TimerID	= Handle(this.TimerT) 
	this\StartTime  = MilliSecs()
	this\CurTime  	= 0
	this\TimerTime	= 0     
	this\Paused		= False
	
	
	Return this\TimerID                       
	
End Function

Function vdGetTimer(TimerID,TypeOfTimer=cTimeTimer)
	
	this.TimerT = Object.TimerT(TimerID)
	
	Return this\TimerTime
	
End Function

Function vdSetAllTimersPause(Pause)
	
	For this.TimerT=Each TimerT
		this\Paused=Pause
	Next
	
End Function


Function vdUpdateTimers()
	Local TimeDiff,NewCurTime
	
	For this.TimerT=Each TimerT
		
		NewCurTime=MilliSecs()-this\StartTime
		TimeDiff=NewCurTime-this\CurTime
		this\CurTime=NewCurTime
		
		If this\Paused=False
			this\TimerTime=this\TimerTime+TimeDiff 
		EndIf
	Next
	
End Function