Bonjour à toutes et tous,
Je cherche un moyen simple de changer le fond d'écran par programmation.
J'ai trouvé un exemple sous Delphi, mais je n'arrive pas à le porter sous Lazarus car je ne sais pas dans quelle unité est déclarée IActiveDesktop.
Voici le source
J'ai mis les unites shlobj, comobj, et shellapi.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Procedure P_changefondecran(Const Stp_image : String; Wp_style : Dword); const GUID: TGUID = '{75048700-EF1F-11D0-9888-006097DEACF9}'; var ComObj : IUnknown; Buffer : PWideChar; WallPaperOpt : TWallPaperOpt; begin if not FileExists(Stp_image) then Exit; Buffer := AllocMem(MAX_PATH); StringToWideChar(Stp_image, Buffer, MAX_PATH); WallPaperOpt.dwStyle := wp_Style; WallPaperOpt.dwSize := SizeOf(WallPaperOpt); ComObj := CreateComObject(GUID); with ComObj as IActiveDesktop do begin SetWallpaperOptions(WallPaperOpt, 0); SetWallpaper(Buffer, 0); ApplyChanges(AD_APPLY_ALL); //(AD_APPLY_ALL or AD_APPLY_FORCE); end; FreeMem(Buffer); End;
Dans ShellApi, j'ai trouvé ces lignes
Je me dis donc, que IActiveDesktop doit bien être déclaré quelque part... mais impossible de trouver où !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 //////////////////////////////////////////// // Flags for IActiveDesktop::ApplyChanges() AD_APPLY_SAVE = $00000001; AD_APPLY_HTMLGEN = $00000002; AD_APPLY_REFRESH = $00000004; AD_APPLY_ALL = (AD_APPLY_SAVE or AD_APPLY_HTMLGEN or AD_APPLY_REFRESH); AD_APPLY_FORCE = $00000008; AD_APPLY_BUFFERED_REFRESH = $00000010; AD_APPLY_DYNAMICREFRESH = $00000020; //////////////////////////////////////////// // Flags for IActiveDesktop::GetWallpaperOptions() // IActiveDesktop::SetWallpaperOptions() WPSTYLE_CENTER = 0; WPSTYLE_TILE = 1; WPSTYLE_STRETCH = 2; WPSTYLE_MAX = 3;
Quelqu'un a déjà utilisé ça ?
Merci d'avance
JS
Partager