Change the desktop background in code

Miscellaneous Forums/General Discussion/Change the desktop background in code

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's a little app that will change the background regularly:
Framework brl.linkedlist
Import brl.filesystem
Import brl.retro
Import leadwerks.appsettings

Const SPI_SETDESKWALLPAPER=20

Extern "win32"
	Function SystemParametersInfoA:Int(uiAction,uiParam,pvParam$z,fWinIni)
EndExtern

bgpath$=AppDir
LoadAppSettings()
bgpath=AppSetting("wallpaperdir",bgpath)

Local list:TList=New TList

d=ReadDir(bgpath)
If Not d End
Repeat
	file$=NextFile(d)
	If file="" Exit
	If Lower(ExtractExt(file))="bmp"
		count:+1
		list.addlast bgpath+"/"+file
	EndIf
Forever
CloseDir d

SeedRnd MilliSecs()
Repeat

	Delay 1000*60*5

	bgfile$=String(list.valueatindex(Rand(0,count-1)))
	SystemParametersInfoA SPI_SETDESKWALLPAPER,0,bgfile,0

Forever
End