Using IActiveDesktop in C#
-
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 .:.
-
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 .:.
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 fromSystem.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-----
-
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 fromSystem.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-----
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 .:.
-
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 .:.
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 theIActiveDesktop
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 theSystemParametersInfo
method would be much easier. Just use theSystem.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-----
-
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 theIActiveDesktop
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 theSystemParametersInfo
method would be much easier. Just use theSystem.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-----
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 .:.