We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Wallpapers in win95

xer_soft asked
Medium Priority
Last Modified: 2010-05-03
How do you change the wallpaper in win95 using VB5.0? Every one on my computer
has their own login and I only want to change it for my profile not every one.
Watch Question

There's an API call to do that.  I don't remember which function.  If I have time tonight, I'll check it.


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

' Put th picture c:\windows\setup.bmp as wallpaper
          Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "c:\windows\setup.bmp", SPIF_UPDATEINIFILE)

 ' get rid of Wall Paper        
          Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "", SPIF_UPDATEINIFILE)


This does not work! The only thing I changed is to make the function work anywhere in the program...

Then you need to declare in a module:

                 Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam
       As Long,
                 ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long


DQ- Thank you very much. This works great! I thank you very much. You have the points as far as I am concerned with an A  but if you please can answer this one more queston I will up the points to 70. How do you change other things like to tile an immage or not to tile an image. That is really my only other question. If you don't have an answer post another answer saying something and I will give you your 50 points.

  I am not sure what you are asking, DO you want to tile a bitmap?
Here is the code:

         #If Win32 Then
             Declare Function BitBlt Lib "gdi32" _
             (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
             ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
             ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
             Declare Function BitBlt Lib "gdi" (ByVal hDestDC As Integer, _
             ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
             ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, _
             ByVal ySrc As Integer, ByVal dwRop As Long) As Integer
         #End If
         Const SRCCOPY = &HCC0020

  ' As you can see here I used conditional compilation to use the proper API call
  'for either the 32 bit or 16 bit environment.

 ' Now we will make the TilePicture procedure that will tile the picture passed
'to it onto the form. Go ahead and enter the code as you see it below.

         Public Sub TilePicture(frmDest As Form, picSource As PictureBox)
             Dim iPicWidth As Integer
             Dim iPicHeight As Integer
             Dim iFormWidth As Integer
             Dim iFormHeight As Integer
             Dim x As Integer
             Dim y As Integer
             Dim iResult As Integer
             Dim iOldScale As Integer
             'Get the picture width and height in pixels
             iOldScale = picSource.ScaleMode
             picSource.ScaleMode = 3
             iPicWidth = picSource.ScaleWidth
             iPicHeight = picSource.ScaleHeight
             picSource.ScaleMode = iOldScale
             'Get the Forms width and height in pixels
             iFormWidth = frmDest.Width / Screen.TwipsPerPixelX
             iFormHeight = frmDest.Height / Screen.TwipsPerPixelY
             For x = 0 To iFormWidth Step iPicWidth
                 For y = 0 To iFormHeight Step iPicHeight
                     iResult = BitBlt(frmDest.hDC, x, y, iPicWidth, iPicHeight, _
                     picSource.hDC, 0, 0, SRCCOPY)
         End Sub

   '     As you can see we are passsing two parameters to this function.
'         The destination form and the source picture.

'         The first thing we do is get the width of the source picture in pixels.
'    In this example I temporarily change the Scalemode to pixels then after
'     I get the  width and height I change it back.

' Next I get the Form width and height. I did this differently than the Picture just
' to show a different way to do the same thing.

'  Finally we loop through the x and y values and BitBlt the picture onto the form.

'         Now to test this procedure you will need to create a new form and place
'    a picturebox anywhere on the form. Set the picture property to anybitmap.
'         Try a smaller bitmap so you can see that it is tiling properly.

'         In the Form_Paint event insert this code.

         Private Sub Form_Paint()
             TilePicture Me, Picture1
         End Sub


DQ - I'm sorry for not being more clear... What I meant what if you wanted to tile a bitmap for use as a walpaper. When you go into the control panal ... display... backround   you get all kinds of other properties like pattern, wallpaper, and display. I would like to know how to change the display from tile to center or center to tile. Please forgive me for not being more clear. But that is a nice example of Bitblt! Don't worry the points are still yours! If you don't know this then I will ask a new Question some other time. Thank you very much.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


This is good enough. Thanks a bunch for all the help!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.