Solved

Changing TILE/CENTER mode for background

Posted on 1997-10-29
6
426 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
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…

760 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

19 Experts available now in Live!

Get 1:1 Help Now