This shows you the differences between two versions of the page.
setting_20the_20desktop_20wallpaper [2018/03/31 14:19] 127.0.0.1 external edit |
setting_20the_20desktop_20wallpaper [2018/04/17 14:54] (current) richardrussell Added syntax highlighting |
||
---|---|---|---|
Line 3: | Line 3: | ||
//by Jon Ripley, July 2007//\\ \\ | //by Jon Ripley, July 2007//\\ \\ | ||
==== Setting the Desktop wallpaper ==== | ==== Setting the Desktop wallpaper ==== | ||
- | \\ To set the current Desktop wallpaper use the following code:\\ \\ | + | \\ To set the current Desktop wallpaper use the following code: |
+ | |||
+ | <code bb4w> | ||
SPIF_UPDATEINIFILE = 1 | SPIF_UPDATEINIFILE = 1 | ||
SPI_SETDESKWALLPAPER = 20 | SPI_SETDESKWALLPAPER = 20 | ||
SYS "SystemParametersInfo", SPI_SETDESKWALLPAPER, 0, filename$, SPIF_UPDATEINIFILE | SYS "SystemParametersInfo", SPI_SETDESKWALLPAPER, 0, filename$, SPIF_UPDATEINIFILE | ||
- | \\ Here the **filename$** parameter is the full path to a bitmap image (.BMP) to set as the Desktop wallpaper. To use images in unsupported file formats - such as .GIF and .PNG - as Desktop wallpaper they must first be converted to Window bitmap (.BMP) format. Under Windows Vista **filename$** can point to a JPEG image (.JPG or .JPEG). \\ \\ | + | </code> |
+ | |||
+ | Here the **filename$** parameter is the full path to a bitmap image (.BMP) to set as the Desktop wallpaper. To use images in unsupported file formats - such as .GIF and .PNG - as Desktop wallpaper they must first be converted to Window bitmap (.BMP) format. Under Windows Vista **filename$** can point to a JPEG image (.JPG or .JPEG). | ||
==== Removing the Desktop wallpaper ==== | ==== Removing the Desktop wallpaper ==== | ||
- | \\ To remove the current Desktop wallpaper use code similar to the following:\\ \\ | + | |
+ | To remove the current Desktop wallpaper use code similar to the following: | ||
+ | |||
+ | <code bb4w> | ||
SPIF_UPDATEINIFILE = 1 | SPIF_UPDATEINIFILE = 1 | ||
SPI_SETDESKWALLPAPER = 20 | SPI_SETDESKWALLPAPER = 20 | ||
SYS "SystemParametersInfo", SPI_SETDESKWALLPAPER, 0, "", SPIF_UPDATEINIFILE | SYS "SystemParametersInfo", SPI_SETDESKWALLPAPER, 0, "", SPIF_UPDATEINIFILE | ||
- | \\ Here the only difference is that the file name parameter is empty.\\ \\ | + | </code> |
+ | |||
+ | Here the only difference is that the file name parameter is empty. | ||
==== Retrieving the current Desktop wallpaper ==== | ==== Retrieving the current Desktop wallpaper ==== | ||
- | \\ To retrieve the full path to the current Desktop wallpaper use code similar to the following:\\ \\ | + | |
+ | To retrieve the full path to the current Desktop wallpaper use code similar to the following: | ||
+ | |||
+ | <code bb4w> | ||
MAX_PATH = 260 | MAX_PATH = 260 | ||
DIM wp% MAX_PATH - 1 | DIM wp% MAX_PATH - 1 | ||
Line 21: | Line 35: | ||
SYS "SystemParametersInfo", SPI_GETDESKWALLPAPER, MAX_PATH, wp%, 0 | SYS "SystemParametersInfo", SPI_GETDESKWALLPAPER, MAX_PATH, wp%, 0 | ||
BackDrop$ = $$wp% | BackDrop$ = $$wp% | ||
- | \\ Here **BackDrop$** will contain the full path to the current Desktop wallpaper or NUL if no wallpaper is in use. As always, make sure you execute the **DIM** statement only once, or use **DIM LOCAL**, to avoid a memory leak and an eventual **No room** error. | + | </code> |
+ | |||
+ | Here **BackDrop$** will contain the full path to the current Desktop wallpaper or NUL if no wallpaper is in use. As always, make sure you execute the **DIM** statement only once, or use **DIM LOCAL**, to avoid a memory leak and an eventual **No room** error. |