Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing TILE/CENTER mode for background

Posted on 1997-10-29
6
Medium Priority
?
438 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
  • 3
  • 3
6 Comments
 
LVL 3

Author Comment

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

Accepted Solution

by:
wolfcrag earned 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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!

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Suggested Courses

885 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