DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to change Wallpaper's properties?

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    How to change Wallpaper's properties?

    [Originally posted by mr_necromancer]

    I wanna know is it possible to change wallpaper's properties such as tiled, centered, or stretch??? If it is possible, please tell me which registry to modify, or delete, or add....


    ;;;;;;;;;;;; GERSON ;;;;;;;;;;;

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:How to change Wallpaper's properties?

    [Originally posted by Karlis]

    The following code sets and retrieves
    wallpaper properties through the Registry:-

    Option Explicit
    '
    ' declare wallpaper change function
    '
    Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
    '
    ' Declare registration database functions
    '
    Const REG_SZ = 1
    Const HKEY_CURRENT_USER = &H80000001
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    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 RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue 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, ByVal lpData As String, ByVal cbData As Long) As Long
    '
    ' declare API constants
    '
    Const SPI_SETDESKWALLPAPER = 20
    Const SPIF_SENDWININICHANGE = &H2
    Const SPIF_UPDATEINIFILE = &H1


    Private Sub UpdateWinIni()
    SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ByVal "", SPIF_SENDWININICHANGE
    End Sub


    '
    ' Tile/center wall paper based on check box.
    '
    Private Sub chkTile_Click()
    Dim Ret As Long
    Dim KeyName As String
    Dim KeyValue As String
    Dim KeyHandle As Long
    Dim KeyValueLength As Long
    '
    ' make sure tiling is set properly
    '
    KeyValue = CStr(chkTile.Value)
    KeyName = "desktop\TileWallpaper"
    KeyValueLength = Len(KeyValue) + 1
    Ret = RegOpenKey(HKEY_CURRENT_USER, "Control Panel\desktop", KeyHandle)
    If Ret = 0 Then
    Ret = RegSetValueEx(KeyHandle, "TileWallpaper", 0, REG_SZ, KeyValue, KeyValueLength)
    Ret = RegCloseKey(KeyHandle)
    End If
    UpdateWinIni
    End Sub

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:How to change Wallpaper's properties?

    [Originally posted by mr_necromancer]

    Thank you... your code really works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center