Wallpapers in win95

Posted on 1998-07-31
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.
Question by:xer_soft
  • 4
  • 4

Expert Comment

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

Expert Comment

ID: 1467375

          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)

Author Comment

ID: 1467376
This does not work! The only thing I changed is to make the function work anywhere in the program...
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Expert Comment

ID: 1467377
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

Author Comment

ID: 1467378
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.

Expert Comment

ID: 1467379
  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

Author Comment

ID: 1467380
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.

Accepted Solution

DQ earned 50 total points
ID: 1467381
I don't think I know the answer, nor the question. you can using the tile code when you want to tile it, and not using it if you don't want.

Author Comment

ID: 1467382
This is good enough. Thanks a bunch for all the help!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

839 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