Solved

Changing TILE/CENTER mode for background

Posted on 1997-10-29
6
435 Views
Last Modified: 2008-02-26
I have a program in Windows 3.11 that randomly changes the background picture from a list of selected images. I tried to convert it to Windows 95 and found that I can't alter the TILE/CENTER value the same way I did before in Win3.11...

Here is the code I am currently using.



  SaveSetting "Win", "Desktop", "TileWallPaper", Mode
  z = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, Pic _
      &  ".bmp", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)



Although the picture changes, the tile mode doesn't when I try this in Win95. Anyone know how to change the TileWallPaper mode under windows 95?
0
Comment
Question by:schworak
[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
  • 3
  • 3
6 Comments
 
LVL 3

Author Comment

by:schworak
ID: 1439194
Edited text of question
0
 
LVL 3

Accepted Solution

by:
wolfcrag earned 50 total points
ID: 1439195
The info for that is stored in the the registry in the folowing key:

HKEY_CURRENT_USER/ControlPanel/Desktop/TileWallpaper

A value of "0" means no tiling, a value of "1" means tiling.
So, change the value of this registry setting, then make your call to SystemParametersInfo. After the call, your wallpaper will change to Pic & ".bmp" and to whatever mode you specified in the registry (tiled or cenetered).

If you need help on changing a registry value, let me know!
0
 
LVL 3

Author Comment

by:schworak
ID: 1439196
Yes, if you could give a little more detail on changing the registry I would appreciate it.  Thank you!
0
Independent Software Vendors: 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:wolfcrag
ID: 1439197
OK, schworak, I'll send you the answer later tonight.  
0
 
LVL 3

Expert Comment

by:wolfcrag
ID: 1439198
Schworak,

   Create a new project, add a command button (Command1) and textbox (Text1) to it. Then copy and paste the following code in to the general declarations section of the form:

*******COPY BELOW THIS LINE********
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_DYN_DATA = &H80000004

Const REG_SZ = 1

' Registry API prototypes
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long


Private Sub Command1_Click()
' Open the key by attempting to create it. If it
' already exists we get back an ID.
Dim lKeyID As Long, plStatus As Long, lBufferSize As Long, ptSubKey As String
Dim tKeyValue As String, ptKeyValue As String
ptSubKey = "Control Panel\DeskTop"
plStatus = RegCreateKey(HKEY_CURRENT_USER, ptSubKey, lKeyID)
Debug.Print plStatus, lKeyID
               
If plStatus <> 0 Then
    ' Call failed, can't open the key so exit
    Exit Sub
End If

' Determine the size of the data in the registry entry
plStatus = RegQueryValueEx(lKeyID, "TileWallpaper", 0&, REG_SZ, 0&, lBufferSize)
               
Debug.Print plStatus, lBufferSize, "Buffer Size"
If lBufferSize < 2 Then
    ' No data value available
    Exit Sub
End If

' Allocate the needed space fopr the key data
tKeyValue = String(lBufferSize + 1, " ")

' Get the value of the registry entry
plStatus = RegQueryValueEx(lKeyID, "TileWallpaper", 0&, REG_SZ, ByVal tKeyValue, lBufferSize)

' Trim the null at the end of the returned value
ptKeyValue = Left$(tKeyValue, lBufferSize - 1)

' Show original value in the tex box
Text1.Text = ptKeyValue
' Change the registry value to the opposite of what it was
If ptKeyValue = "1" Then
    ptKeyValue = "0"
Else
    ptKeyValue = "1"
End If
plStatus = RegSetValueEx(lKeyID, "TileWallpaper", 0&, REG_SZ, ByVal ptKeyValue, Len(ptKeyValue) + 1)
End Sub

*******COPY ABOVE THIS LINE********

    This program will read the TileWallpaper value, show it in the textbox, and then change it to it's opposite value (e.g. if it's "1", then it's changed to "0", or vice versa)

    I believe this should be plenty of info for you to solve your problem! :-) But let me know if there are any problems.
0
 
LVL 3

Author Comment

by:schworak
ID: 1439199
Thanks for all your help. Your extra efforts are appreciated a great deal.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

710 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