Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Wallpaper per Monitor? (https://www.delphipraxis.net/212428-wallpaper-per-monitor.html)

KodeZwerg 10. Feb 2023 14:49

AW: Wallpaper per Monitor?
 
Zitat:

Zitat von Detlev (Beitrag 1518528)
Wie lautet das Code-Snippet als Delphi-Code?

Ich würde es so umsetzen:
Delphi-Quellcode:
function SetWallpaperAPI(const AMonitor: Integer; const AFilename: string): Boolean;
var
  LIWallpaper   : IDesktopWallpaper;
  LMonitorID,
  LWallpaperFile : PWideChar;
  LCount        : DWORD;
begin
  Result := False;
  if (AMonitor < 0) then
    Exit;
  if not FileExists(AFilename) then
    Exit;
  LWallpaperFile := PWideChar(AFilename);
  LIWallpaper   := CoDesktopWallpaper.Create;
  try
    OleCheck(LIWallpaper.GetMonitorDevicePathCount(LCount));
    if (AMonitor >= LCount) then
      Exit;
    OleCheck(LIWallpaper.GetMonitorDevicePathAt(AMonitor, LMonitorID));
    OleCheck(LIWallpaper.SetWallpaper(LMonitorID, LWallpaperFile));
  finally
    Result := True;
  end;
end;

Detlev 10. Feb 2023 14:54

AW: Wallpaper per Monitor?
 
Danke, werde ich mal ausprobieren!


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:18 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz