• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Setting a wallpaper (windows desktop)

Hi

I have a .gif image. i want to create a command button, when this is clicked i want it to change the current wall paper to the image i have (.gif).

i want to do this on two versions of the software im making (one for windows xp and one for windows 98)

simple but im new to the basic language.

note: i want the .gif file to be compiled in the project so that i dont need to use a installer. is this possible.

thanks in advance for any help:)
0
samsungfanatic
Asked:
samsungfanatic
1 Solution
 
JonyvCommented:
I think this will do the trick on both Win98 and XP:

You can store a picture in your application by adding a picturebox, loading your picture and making the picture box invisible.

Example: Create a new VB project, add a button and a picturebox, load your wallpaer into the picturebox and paste the following code in your form:


Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Const SPI_SETDESKWALLPAPER = 20

Private Sub Command1_Click()

Dim WallpaperFile As String

WallpaperFile = "c:\wallpaper.bmp"  'Select where your picture file will be saved here.

SavePicture Picture1.Picture, WallpaperFile

Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal WallpaperFile, 0)

End Sub

0
 
samsungfanaticAuthor Commented:
hi,

it saves the file to c drive but does'nt set it as the desktop wall paper.. any ideas why? i only tried it on win 98 not xp yet.

thanks for help
0
 
samsungfanaticAuthor Commented:
ok... only changes wall paper after i refresh the desktop (right click and refresh), any-way of refreshing the desktop through basic?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JonyvCommented:
I don't have any Win98 installation, so I can't test this, but try the following.

Add
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1
to the code and change
Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal WallpaperFile, 0)
to
Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal WallpaperFile, SPIF_SENDWININICHANGE + SPIF_UPDATEINIFILE)

That might work.
0
 
FunkyMeisterCommented:
One other consideration to think of, is "Active Desktop".  To be safe, its always best to set both Active Desktop and the normal desktop backgrounds to the same values (that way, if it's on or off, you still see the picture).

You can easily find around the net, a registry module that'll let you change string values in the registry, the following is best to set:

"HKEY_CURRENT_USER\Control Panel\Desktop\TileWallPaper" to "0" [don't tile the wallpaper]
"HKEY_CURRENT_USER\Control Panel\Desktop\WallpaperStyle" to "0" [don't stretch/center the wallpaper]

"HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper" to WallpaperFile [name of the file you're using]

Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal WallpaperFile, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)

Doing both will ensure that your picture shows up in either Active Desktop or not.
0
 
CleanupPingCommented:
Hi samsungfanatic,
This old question (QID 20560933) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
YensidModCommented:
This question is PAQed and no points refunded (of 25)

YensidMod
Expert Exchange Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now