How To Make A Desktop Wallpaper Changer VB.Net

SOLVED Discussion in 'Web Design & Coding' started by Comptech, Dec 13, 2011.

  1. Comptech

    Comptech ICT Technican

    Joined:
    Dec 11, 2011
    Messages:
    16
    Likes Received:
    14
    Location:
    UK
    Add the following Items


    1. Label
    2. PictureBox
    3. Textbox
    4. 2 Buttons
    Name label 1 Picture Location


    Name Button 1 Browse and place this next to the textbox


    Add the Picturebox where you like


    and Finally add the last button beneth the pciturebox and name the button Apply



    Codeing



    [FONT=&quot]Public[/FONT][FONT=&quot] Class Form1[/FONT]
    [FONT=&quot] Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer[/FONT]
    [FONT=&quot] Private Const SETDESKWALLPAPER = 20[/FONT]
    [FONT=&quot] Private Const UPDATEINIFILE = &H1[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click[/FONT]
    [FONT=&quot] Dim dlg As New OpenFileDialog[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot] dlg.Title = "Choose Desktop background image"[/FONT]
    [FONT=&quot] dlg.Filter = ""[/FONT]
    [FONT=&quot] If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then[/FONT]
    [FONT=&quot] TextBox1.Text = dlg.FileName[/FONT]
    [FONT=&quot] PictureBox1.BackgroundImage = Image.FromFile(dlg.FileName)[/FONT]
    [FONT=&quot] PictureBox1.BackgroundImageLayout = ImageLayout.Stretch[/FONT]
    [FONT=&quot] End If[/FONT]
    [FONT=&quot] End Sub[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot] Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click[/FONT]
    [FONT=&quot] SystemParametersInfo(SETDESKWALLPAPER, 0, TextBox1.Text, UPDATEINIFILE)[/FONT]
    [FONT=&quot] End Sub[/FONT]
    [FONT=&quot]End[/FONT][FONT=&quot] Class[/FONT]

    [FONT=&quot][/FONT]
    [FONT=&quot]Breakdown of code;[/FONT]

    [FONT=&quot][/FONT]

    Apply Button

    [FONT=&quot]SystemParametersInfo(SETDESKWALLPAPER, 0, TextBox1.Text, UPDATEINIFILE)[/FONT]


    Browse

    [FONT=&quot]Dim[/FONT][FONT=&quot] dlg As New OpenFileDialog[/FONT]
    [FONT=&quot] [/FONT]
    [FONT=&quot] dlg.Title = "Choose Desktop background image"[/FONT]
    [FONT=&quot] dlg.Filter = ""[/FONT]
    [FONT=&quot] If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then[/FONT]
    [FONT=&quot] TextBox1.Text = dlg.FileName[/FONT]
    [FONT=&quot] PictureBox1.BackgroundImage = Image.FromFile(dlg.FileName)[/FONT]
    [FONT=&quot] PictureBox1.BackgroundImageLayout = ImageLayout.Stretch[/FONT]
    [FONT=&quot] End If[/FONT]


    Declare the function

    [FONT=&quot]Public[/FONT][FONT=&quot] Class Form1[/FONT]
    [FONT=&quot] Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer[/FONT]
    [FONT=&quot] Private Const SETDESKWALLPAPER = 20[/FONT]
    [FONT=&quot] Private Const UPDATEINIFILE = &H1[/FONT]

    [FONT=&quot][/FONT]
    [FONT=&quot]"You have to declare the fuction just below Public Class Form1[/FONT]

    [FONT=&quot][/FONT]



    [FONT=&quot][/FONT]

    [FONT=&quot][/FONT]
    [FONT=&quot]Hope This Helps
    [/FONT]

    [FONT=&quot][/FONT]
    [FONT=&quot]Kind Regards[/FONT]

    [FONT=&quot][/FONT]
    [FONT=&quot]Bradley
    [/FONT]

     
    Comptech, Dec 13, 2011
    #1
    Zeus likes this.
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. jetset707

    MS Net Meeting > Desktop Does Not Load

    jetset707, Oct 23, 2004, in forum: Software
    Replies:
    3
    Views:
    754
    davi99
    Oct 23, 2004
  2. blahtoday

    Voice changer

    blahtoday, Jan 26, 2005, in forum: General Discussion
    Replies:
    3
    Views:
    869
  3. JEMASCOLA

    Can't Add Desktop Wallpaper

    JEMASCOLA, Oct 6, 2008, in forum: Software
    Replies:
    4
    Views:
    1,275
    JEMASCOLA
    Oct 14, 2008
  4. Sluggo

    time changer

    Sluggo, Sep 3, 2003, in forum: Computing
    Replies:
    10
    Views:
    659
    Sluggo
    Sep 7, 2003
  5. lynx

    Desktop wallpaper

    lynx, Dec 4, 2007, in forum: Computing
    Replies:
    1
    Views:
    397
  6. Nick O'Tyme
    Replies:
    0
    Views:
    1,554
    Nick O'Tyme
    Feb 19, 2008
  7. Martin Schneider

    ADIC DAT Changer not visible

    Martin Schneider, Mar 3, 2004, in forum: Backup Software
    Replies:
    0
    Views:
    460
    Martin Schneider
    Mar 3, 2004
  8. Comptech

    SOLVED How To Make A Binary Converter VB.Net

    Comptech, Dec 13, 2011, in forum: Web Design & Coding
    Replies:
    1
    Views:
    6,732
    AceInfinity
    Aug 13, 2012
Loading...