Solved

Changing TILE/CENTER mode for background

Posted on 1997-10-29
6
436 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 14 hours left to enroll

623 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