?
Solved

Setting a wallpaper (windows desktop)

Posted on 2003-03-24
7
Medium Priority
?
173 Views
Last Modified: 2010-05-01
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
Comment
Question by:samsungfanatic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:Jonyv
ID: 8195559
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
 

Author Comment

by:samsungfanatic
ID: 8197341
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
 

Author Comment

by:samsungfanatic
ID: 8197430
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!

 
LVL 3

Expert Comment

by:Jonyv
ID: 8197831
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
 
LVL 1

Expert Comment

by:FunkyMeister
ID: 8199795
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
 

Expert Comment

by:CleanupPing
ID: 8531738
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
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9496094
This question is PAQed and no points refunded (of 25)

YensidMod
Expert Exchange Moderator
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question