Article View: borland.public.cppbuilder.nativeapi
Article #10965Re: Changing the Desktop Wallpaper
From: Robert Hoover
Date: Mon, 08 Mar 2004 19:45
Date: Mon, 08 Mar 2004 19:45
87 lines
3469 bytes
3469 bytes
Thanks, Remy!
I've got the code in place and am getting the following error:
Undefined symbol 'IActiveDesktop'
Could my header file be an incompatible version? Do I need to #define
something before #including?
Thanks,
Rob
____________________________________________________________
#include <shlobj.h>
#include <utilcls.h>
// change image on desktop, requires ActiveDesktop enabled
void SetDesktopWallpaper(char *filename)
{
// pointer to object
IActiveDesktop *pActiveDesktop;
// create an instance of the Active Desktop
HRESULT hResult = CoCreateInstance(CLSID_ActiveDesktop, NULL,
CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (void**)&pActiveDesktop);
// validate result
if (hResult == S_OK)
{
// alter desktop image
pActiveDesktop->SetWallpaper(filename, 0);
pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
}
// release resources
pActiveDesktop->Release();
}
____________________________________________________________________________
____________________________________________
"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:404cc051$1@newsgroups.borland.com...
"Robert Hoover" <not.a.real.address@anywhere...sorry> wrote in message
news:404cb832@newsgroups.borland.com...
> But, it only accepts BITMAPs. Is there a VCL object
> or function to accomplish the same thing, adding JPG
> or other formats?
In order to support formats other than BMP, you must first enable
ActiveDesktop in the system's Control Panel. Then you can access the
desktop programmably via the IActiveDesktop interface and call its
SetWallpaper method() (and optionally its SetWallpaperOptions() method as
well). For example.
#include <shlobj.h>
#include <utilcls.h>
TComInterface<IActiveDesktop> ActiveDesktop;
if( SUCCEEDED(CoCreateInstance(CLSID_ActiveDesktop, NULL,
CLSCTX_INPROC_SERVER, IID_IActiveDesktop, (LPVOID*)&ActiveDesktop)) )
{
ActiveDesktop->SetWallpaper(L"c:\\path to\\MyImage.jpg", 0);
ActiveDesktop->ApplyChanges(AD_APPLY_ALL);
}
Have a look at the following articles for more details:
Using the Active Desktop Object
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersgu
ide/shell_adv/activedesktop.asp
IActiveDesktop Interface
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/ifa
ces/iactivedesktop/iactivedesktop.asp
Gambit
Technical Details
Message-ID:
<404ccd51@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<404cb832@newsgroups.borland.com> <404cc051$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5d6d0144e51c775c X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-08 12:11:01 PST From: "Robert Hoover" <not.a.real.address@anywhere...sorry> Newsgroups: borland.public.cppbuilder.nativeapi References: <404cb832@newsgroups.borland.com> <404cc051$1@newsgroups.borland.com> Subject: Re: Changing the Desktop Wallpaper Date: Mon, 8 Mar 2004 14:45:18 -0500 Lines: 90 Organization: TriTekCorp.com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 67.142.18.164 Message-ID: <404ccd51@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1078775121 67.142.18.164 (8 Mar 2004 11:45:21 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail