Solved

Changing TILE/CENTER mode for background

Posted on 1997-10-29
6
430 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 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now