Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Changing Wallpaper

Wazzup guys??!

How can I change the picture that is being used as background in windows, using Visual Basic 6??

Thanks...!!

DennisTheMenace

Comments

  • MicroDotMicroDot Posts: 142Member
    : Wazzup guys??!
    :
    : How can I change the picture that is being used as background in windows, using Visual Basic 6??
    :
    : Thanks...!!
    :
    : DennisTheMenace
    :
    Hi Dennis,
    Use SystemParametersInfo API call to change the wallpaper.
    Try this snippet:

    [code]

    Option Explicit

    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

    Private Const SPI_SETDESKWALLPAPER = 20
    Private Const SPIF_UPDATEINIFILE = &H1
    Private Const SPIF_SENDWININICHANGE = &H2

    'strImage is the name including path to the imagefile
    Private Function SetWallpaper(ByVal strImage As String) As Boolean

    On Error GoTo SW_Err

    SetWallpaper = False
    If Dir(strImage, vbNormal) <> vbNullString Then
    SetWallpaper = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, strImage, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
    Else
    MsgBox strImage & " does not exist", vbExclamation, "Error"
    End If

    Exit Function

    SW_Err:
    Debug.Print "Error in 'SetWallpaper': " & Err.Description
    SetWallpaper = False
    End Function

    [/code]


    [hr]

    [b][blue]//MicroDot[/blue][/b]

  • dionisis84dionisis84 Posts: 69Member
Sign In or Register to comment.