Forum > Graphics

How to set the desktop color

(1/3) > >>

zxandris:
Hello, I was wondering if anyone knows how to set the desktop color in windows please?

Currently I have no idea how to do this.  I have a little routine that sets the desktop background, and I would really like to be able to set the desktop background color too.

Any help would be gratefully appreciated

CJ

Fibonacci:
How about that :D


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Windows, SysUtils, Classes; procedure set_desktopbg_solid_color(color: dword);const  bitmap = #$42#$4D#$3A#$00#$00#$00#$00#$00#$00#$00#$36#$00#$00#$00#$28#$00  +#$00#$00#$01#$00#$00#$00#$01#$00#$00#$00#$01#$00#$18#$00#$00#$00  +#$00#$00#$04#$00#$00#$00#$23#$2E#$00#$00#$23#$2E#$00#$00#$00#$00  +#$00#$00#$00#$00#$00#$00;var  temp: string;begin  with TMemoryStream.Create do begin    Write(bitmap[1], length(bitmap));    color := SwapEndian(color) shr 8;    Write(color, 4);    temp := ExtractFileDir(paramstr(0))+'\1x1.bmp';    SaveToFile(temp);    SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @temp[1], SPIF_UPDATEINIFILE or SPIF_SENDWININICHANGE);    DeleteFile(temp);    Free;  end;end; const  clRed = $0000FF;  clLime = $00FF00; begin  while true do begin    set_desktopbg_solid_color(clRed);    sleep(1000);    set_desktopbg_solid_color(clLime);    sleep(1000);  end;end.

zxandris:
Not entirely sure I'm reading this right but it appears that sets the wallpaper with a colored bitmap.  That is unfortunately definitely not what I want.  In control panel you can set the background color of the desktop seperately from the wallpaper.  That's what I'm trying to do.

But thank you for the reply, and please do tell me if I'm not reading that right.

CJ


--- Quote from: Fibonacci on December 09, 2024, 12:24:59 am ---How about that :D


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Windows, SysUtils, Classes; procedure set_desktopbg_solid_color(color: dword);const  bitmap = #$42#$4D#$3A#$00#$00#$00#$00#$00#$00#$00#$36#$00#$00#$00#$28#$00  +#$00#$00#$01#$00#$00#$00#$01#$00#$00#$00#$01#$00#$18#$00#$00#$00  +#$00#$00#$04#$00#$00#$00#$23#$2E#$00#$00#$23#$2E#$00#$00#$00#$00  +#$00#$00#$00#$00#$00#$00;var  temp: string;begin  with TMemoryStream.Create do begin    Write(bitmap[1], length(bitmap));    color := SwapEndian(color) shr 8;    Write(color, 4);    temp := ExtractFileDir(paramstr(0))+'\1x1.bmp';    SaveToFile(temp);    SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @temp[1], SPIF_UPDATEINIFILE or SPIF_SENDWININICHANGE);    DeleteFile(temp);    Free;  end;end; const  clRed = $0000FF;  clLime = $00FF00; begin  while true do begin    set_desktopbg_solid_color(clRed);    sleep(1000);    set_desktopbg_solid_color(clLime);    sleep(1000);  end;end.
--- End quote ---

TRon:

--- Quote from: zxandris on December 09, 2024, 12:27:51 am ---In control panel you can set the background color of the desktop seperately from the wallpaper.  That's what I'm trying to do.

--- End quote ---
Then do it in the same way but in code, see also these SO answers.

There is a registry class.

Fibonacci:
Oh

This color can be obtained by the DwmGetColorizationColor() function, but there is no Set variant of this function, so you need to do it through the registry

Navigation

[0] Message Index

[#] Next page

Go to full version