Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Using IActiveDesktop in C#

Using IActiveDesktop in C#

Scheduled Pinned Locked Moved C#
csharpvisual-studioquestion
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Okeno Palmer
    wrote on last edited by
    #1

    Greets all, I'm trying to write an application in C# that will allow me to change to the desktop wallpaper. I would also like to place a calendar control on the Desktop using this application. I tried adding a reference to shell32.dll in Visual Studio 2003 but the IActiveDesktop interface is not listed by VS when I examine the reference. Any suggestions as to how I may go about getting access to the IActiveDesktop from C#?? .:. Keno .:.

    H 1 Reply Last reply
    0
    • O Okeno Palmer

      Greets all, I'm trying to write an application in C# that will allow me to change to the desktop wallpaper. I would also like to place a calendar control on the Desktop using this application. I tried adding a reference to shell32.dll in Visual Studio 2003 but the IActiveDesktop interface is not listed by VS when I examine the reference. Any suggestions as to how I may go about getting access to the IActiveDesktop from C#?? .:. Keno .:.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      There's a much simpler way: http://www.c-sharpcorner.com/Code/2002/Sept/ChangeWallpaper.asp[^] Using the IActiveDesktop interface, you'd have to declare it manually using various attributes from System.Runtime.InteropServices and go to a lot of trouble creating the instance from CLSID_ActiveDesktop (defined in shlguid.h) when only a simple function call is needed. See the link above for an example. This was the 3rd result when I googled for "C# desktop wallpaper".

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      O 1 Reply Last reply
      0
      • H Heath Stewart

        There's a much simpler way: http://www.c-sharpcorner.com/Code/2002/Sept/ChangeWallpaper.asp[^] Using the IActiveDesktop interface, you'd have to declare it manually using various attributes from System.Runtime.InteropServices and go to a lot of trouble creating the instance from CLSID_ActiveDesktop (defined in shlguid.h) when only a simple function call is needed. See the link above for an example. This was the 3rd result when I googled for "C# desktop wallpaper".

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        O Offline
        O Offline
        Okeno Palmer
        wrote on last edited by
        #3

        Heath, Thanks for the reply! I did see that link and it does work for changing hte wallpaper. However I think I may have to go the long way as I would like to have an effect like WebShots where I can have a Calnedar control displayed on the desktop. Would you recommend I go with C# or C++ to implement this control display? I'd really love to do it with C# to see what is involved though so If you can point me to any useful resources and how to start that would be appreciated. .:. Keno .:.

        H 1 Reply Last reply
        0
        • O Okeno Palmer

          Heath, Thanks for the reply! I did see that link and it does work for changing hte wallpaper. However I think I may have to go the long way as I would like to have an effect like WebShots where I can have a Calnedar control displayed on the desktop. Would you recommend I go with C# or C++ to implement this control display? I'd really love to do it with C# to see what is involved though so If you can point me to any useful resources and how to start that would be appreciated. .:. Keno .:.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          First of all, read the documentation for the System.Runtime.InteropServices elements in the .NET Framework SDK documentation. It's important to understand that. There's also a couple articles about COM interop in .NET that you should read in the articles section of the .NET Framework SDK documentation. Nick Parker has a pretty good one dealing with some of the issues: http://www.codeproject.com/dotnet/nettocom.asp[^] You should also be familiar with some basic COM, since you'll be using a lot of this to use the IActiveDesktop interfaces. There are several articles here on CP that should be useful. Honestly, though, the WebShots calendar is nothing more than a calendar drawn onto an image that is set as wallpaper. It is not an desktop item (at least, not last time I checked). It merely loads an image, paints a calendar on that, saves that image to a temporary spot and sets that as the wallpaper. Again, using the SystemParametersInfo method would be much easier. Just use the System.Drawing classes to load an image (Bitmap class) and draw on it (Graphics class), then save it and use the method. Simple.

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          O 1 Reply Last reply
          0
          • H Heath Stewart

            First of all, read the documentation for the System.Runtime.InteropServices elements in the .NET Framework SDK documentation. It's important to understand that. There's also a couple articles about COM interop in .NET that you should read in the articles section of the .NET Framework SDK documentation. Nick Parker has a pretty good one dealing with some of the issues: http://www.codeproject.com/dotnet/nettocom.asp[^] You should also be familiar with some basic COM, since you'll be using a lot of this to use the IActiveDesktop interfaces. There are several articles here on CP that should be useful. Honestly, though, the WebShots calendar is nothing more than a calendar drawn onto an image that is set as wallpaper. It is not an desktop item (at least, not last time I checked). It merely loads an image, paints a calendar on that, saves that image to a temporary spot and sets that as the wallpaper. Again, using the SystemParametersInfo method would be much easier. Just use the System.Drawing classes to load an image (Bitmap class) and draw on it (Graphics class), then save it and use the method. Simple.

            -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

            O Offline
            O Offline
            Okeno Palmer
            wrote on last edited by
            #5

            Great info there Heath! I thought that Calendar was a control! Well it seems then that I should be able to get this done using C#. I'll have a look on those articles you mentioned. I am currently reading "Essential COM" by Dan Box to learn about COM. Thanks again for all the info, I'll do some reasing and see what I can brew :) .:. Keno .:.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups