(*
/*

CLASS {Set_wallpaper_color|_Pascal_Windows},
UNTESTED, NATIVE:

NATIVE: "uses Set_wallpaper_color;" .
NATIVE: "///COPY Set_wallpaper_color.pas" .

*/
*)

unit Set_wallpaper_color;

interface

uses {$IFDEF LINUX}{$ELSE} Windows, {$ENDIF} AL4;

procedure Set_wallpaper(path: String);
procedure Set_desktop_color(color: Integer);

implementation

const 
	SPI_SETDESKWALLPAPER  = $14;
	SPI_GETDESKWALLPAPER  = $73;
    SPIF_UPDATEINIFILE    = $01;
    SPIF_SENDWININICHANGE = $02;

procedure Set_wallpaper(path: String);
begin
	{$IFDEF LINUX}
	{$ELSE}
    SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, PChar(path),
        SPIF_UPDATEINIFILE or SPIF_SENDWININICHANGE);
    {$ENDIF}
end;

const COLOR_DESKTOP = 1;
        
procedure Set_desktop_color(color: Integer);
{$IFDEF LINUX}
{$ELSE}
var elements: array[0..0] of Integer;
	colors: array[0..0] of Integer;
	buf: array[0..270] of Char;
{$ENDIF}
begin
	{$IFDEF LINUX}
	{$ELSE}
	buf[0] := #0;
	SystemParametersInfo(SPI_GETDESKWALLPAPER, 265, @buf[0], 0);
        
	Writeln(buf);
        
	if buf <> '' then
	begin
		writeln(' - - - - reset');
		buf[0] := #0;
	   SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @buf[0],
	       SPIF_UPDATEINIFILE or SPIF_SENDWININICHANGE);
	end;
        
    //array of elements to change
	elements[0] := COLOR_DESKTOP;
	
	//array of corresponding colors
	colors[0] := color and $FFFFFF;
	
	//set the desktop color using p/invoke
	SetSysColors(1, elements, colors);
	{$ENDIF}
end;

end.

(*
/*

FUN Set_color(INT Color|_RGB), NATIVE : @
	"Set_desktop_color(X_Color);" .

FUN Set_wallpaper(
STR Path|_to_image_BMP_or_JPEG), NATIVE : @
	"Set_wallpaper(X_Path);" .

END

*/
*)
