Setting Desktop Background

BlitzMax Forums/BlitzMax Programming/Setting Desktop Background

GfK(Posted 2010) [#1]
I'm trying to write a bit of code to set the desktop background. It kind of works but I want it to stretch the image to full screen.

Much googling suggests that the code below should work... but it doesn't. It changes the background but it remains centered rather than stretched.

Strict

?Win32
	Const SPI_SETDESKWALLPAPER:Int = $14
	Const	 SPIF_SENDWININICHANGE:Int = $2
	Const	 SPIF_UPDATEINIFILE:Int = $1	

	Extern "win32"	
		Function SystemParametersInfo(uiAction, uiParam, pvParam:Byte Ptr, fWinIni) = "SystemParametersInfoA@16"	
	End Extern
?

setwallpaper("paper2.jpg")

Function SetWallpaper(path:String)
	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path.toCString(), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE)
End Function

What's wrong?


Zeke(Posted 2010) [#2]
http://blogs.msdn.com/coding4fun/archive/2006/10/31/912569.aspx

you need to modify registry.


GfK(Posted 2010) [#3]
you need to modify registry.
Isn't that what SPID_UPDATEINIFILE and SPIF_SENDWININICHANGE do via SystemParametersInfo?

[edit]Ah, never mind. I'm sure there's another way but editing the registry works in Windows 7 at least. Just needs testing in Vista/XP.


Zeke(Posted 2010) [#4]
yes, i think so, but only for current background image.


GfK(Posted 2010) [#5]
Well it works in XP..., and I guess its Vista-safe as well if it works in Windows 7 but I'll try that later.

Thanks!