Splash screen example?

BlitzMax Forums/BlitzMax GUI Programming/Splash screen example?

Hi!

I'd like to show a tiny splash screen before my gui app starts (pure image, no window shown at all). What would be the best way doing this. I remember there was an example that came with bmx, but I can't find it anymore.

Grisu

Hi Grisu.
Here is a small sample. Don't know another way to create a splashscreen.

Strict 


Local Window:TGadget, ListBox:TGadget

'Build the program hidden
Window  = CreateWindow("My program", 100,100,400,400, Null, WINDOW_TITLEBAR|WINDOW_HIDDEN)
ListBox = CreateListBox(0,0,ClientWidth(Window)*0.5, ClientHeight(Window), Window)

For Local i:Int = 0 Until 50
	AddGadgetItem(ListBox, "Item "+i)
Next 


'Show the splashscreen
SplashScreen("c:\splash.png")


'Show the program
ShowGadget(Window)

Repeat 
	
	Select WaitEvent()
		Case EVENT_WINDOWCLOSE
			End
	End Select 
Forever




Function SplashScreen(Url:Object, Time:Int=4)
	Local Pixmap_Splash:TPixmap
	Local Window_Splash:TGadget
	Local Splash_X:Int, Splash_Y:Int
	Local Panel_Splash:TGadget
	Local Timer:TTimer
	Pixmap_Splash = LoadPixmap(Url)
	
	Splash_X = ClientWidth(Desktop())*0.5
	Splash_X:-PixmapWidth(Pixmap_Splash)*0.5
	
	
	Splash_Y = ClientHeight(Desktop())*0.5
	Splash_Y:-PixmapHeight(Pixmap_Splash)*0.5
	
	Window_Splash = CreateWindow("",Splash_X, Splash_Y,PixmapWidth(Pixmap_Splash), PixmapHeight(Pixmap_Splash) ,Null, 0)
	
	
	Panel_Splash = CreatePanel(0,0,ClientWidth(Window_Splash), ClientHeight(Window_Splash), Window_Splash)
	SetPanelPixmap Panel_Splash, Pixmap_Splash
	
	Timer = CreateTimer(1)
	
	Repeat 

		Select WaitEvent()
			Case EVENT_TIMERTICK
			
				If TimerTicks(Timer)=>Time
					Exit
				EndIf
				
		End Select 
	Forever
	
	StopTimer(Timer)
	FreeGadget(Window_Splash)
	Pixmap_Splash = Null
End Function


Mfg Suco

Thanks for the code. That's what I was after.

Modification for close splash with mouse key :

Strict 

Local Window:TGadget, ListBox:TGadget

'Build the program hidden
Window  = CreateWindow("My program", 100,100,400,400, Null, WINDOW_TITLEBAR|WINDOW_HIDDEN)
ListBox = CreateListBox(0,0,ClientWidth(Window)*0.5, ClientHeight(Window), Window)

For Local i:Int = 0 Until 50
	AddGadgetItem(ListBox, "Item "+i)
Next 

'Show the splashscreen
Create_SplashScreen("App_Logo.png")

'Show the program
ShowGadget(Window)

Repeat 
	
	Select WaitEvent()
		Case EVENT_WINDOWCLOSE
			End
	End Select 
Forever




Function Create_SplashScreen(Url:Object, Time:Int=4)
	Local Pixmap_Splash:TPixmap
	Local Window_Splash:TGadget
	
	Local Splash_X:Int
	Local Splash_Y:Int
	
	Local Panel_Splash:TGadget
	Local Timer:TTimer
	
	Pixmap_Splash = LoadPixmap(Url)
	
	Splash_X = ClientWidth(Desktop())*0.5
	Splash_X:-PixmapWidth(Pixmap_Splash)*0.5
	
	
	Splash_Y = ClientHeight(Desktop())*0.5
	Splash_Y:-PixmapHeight(Pixmap_Splash)*0.5
	
	Window_Splash = CreateWindow("",Splash_X, Splash_Y,PixmapWidth(Pixmap_Splash), PixmapHeight(Pixmap_Splash) ,Null, 0)
	
	Panel_Splash = CreatePanel(0,0,ClientWidth(Window_Splash), ClientHeight(Window_Splash), Window_Splash,PANEL_ACTIVE)
	SetPanelPixmap Panel_Splash, Pixmap_Splash
	
	Timer = CreateTimer(1)
	
	Repeat 
		Select PollEvent()
			Case EVENT_TIMERTICK 
			
				If TimerTicks(Timer)=>Time
					Exit
				EndIf
				
			Case EVENT_MOUSEDOWN
				Exit
		End Select 
	Forever
	
	StopTimer(Timer)
	FreeGadget(Window_Splash)
	Pixmap_Splash = Null
End Function