modfy the desktopbackground

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JR

    #1

    modfy the desktopbackground

    Hi,

    how can I change the desktopbackgrou nd in vb.net to a JPG file
    I can do it with a bmp file with the api
    Private Declare Function SystemParameter sInfo Lib "user32" Alias
    "SystemParamete rsInfoA" (ByVal uAction As Integer, ByVal uParam As Integer,
    ByVal lpvParam As String, ByVal fuWinIni As Integer) As Long

    'constants to be used with the above api

    Private Const SPI_SETDESKWALL PAPER As Integer = 20

    Private Const SPIF_UPDATEINIF ILE As Integer = &H1

    Private Const SPIF_SendWinIni Change As Integer = &H2


    Jan


  • Mattias Sjögren

    #2
    Re: modfy the desktopbackgrou nd

    >how can I change the desktopbackgrou nd in vb.net to a JPG file
    >I can do it with a bmp file with the api
    I believe you need to enable Active Desktop and use its COM API
    (IActiveDesktop .SetWallpaper) to use a JPEG image.


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Joergen Bech

      #3
      Re: modfy the desktopbackgrou nd


      Why don't you just convert the jpg file to bmp and set
      the bmp?

      I believe it will take up the same amount of memory once
      Windows has to load and present it anyway.

      Here is a code sample that takes jpgs:


      and here:


      Both cheat by converting the image to bmp before sending
      it to the desktop.

      The desktop properties dialog allows you to pick jpg files
      and if you rename the file you picked, switch to another background,
      then try to select the (now invalid) entry again, it won't work, so
      at first sight it does not look like Windows is creating a local bmp
      copy from the jpg file selected. But it is. Take a look at
      c:\Documents and Settings\<activ e user name>\Local Settings\
      Application Data\Microsoft\ and you will find a file named
      "Wallpaper1.bmp ", which is the currently selected wallpaper
      file converted to bmp. Such a file will not appear if you had
      selected a bmp file, as no conversion needs to take place.

      I tried the supported formats and only bmp files do not cause
      the Wallpaper1.bmp file to be created.

      So either you convert the jpg to bmp or Windows will do it for
      you. It would appear that the Desktop is not going to take a
      jpg directly but needs to go through a cached bmp file.

      Yes, you could go the Active Desktop route, but I am sure
      your users would not like it.

      /Joergen Bech



      On Thu, 21 Jun 2007 16:48:49 GMT, "JR" <x.x@x.xwrote :
      >Hi,
      >
      >how can I change the desktopbackgrou nd in vb.net to a JPG file
      >I can do it with a bmp file with the api
      >Private Declare Function SystemParameter sInfo Lib "user32" Alias
      >"SystemParamet ersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer,
      >ByVal lpvParam As String, ByVal fuWinIni As Integer) As Long
      >
      >'constants to be used with the above api
      >
      >Private Const SPI_SETDESKWALL PAPER As Integer = 20
      >
      >Private Const SPIF_UPDATEINIF ILE As Integer = &H1
      >
      >Private Const SPIF_SendWinIni Change As Integer = &H2
      >
      >
      >Jan
      >

      Comment

      Working...