How about that :D
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.
In control panel you can set the background color of the desktop seperately from the wallpaper. That's what I'm trying to do.Then do it in the same way but in code, see also these SO answers (https://serverfault.com/questions/268423/changing-desktop-solid-color-via-registry).
In control panel you can set the background color of the desktop seperately from the wallpaper. That's what I'm trying to do.Then do it in the same way but in code, see also these SO answers (https://serverfault.com/questions/268423/changing-desktop-solid-color-via-registry).
There is a registry class (https://wiki.freepascal.org/fcl-registry).
int aElements[1] = {COLOR_BACKGROUND};
DWORD aNewColors[1];
aNewColors[0] = RGB(0x80, 0x00, 0x80); // dark purple
SetSysColors(1, aElements, aNewColors);
Seems to be the c way of doing thingsAh yes that seems to be a better approach, see also here (https://learn.microsoft.com/en-us/windows/win32/winmsg/configuration) and here (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsyscolors)
Windows 10 or greater: This value is not supported.
Got it. Now your turn - figure out the colors, create functions and share ;)
uses SysUtils, Registry; function tohex(p: pointer; len: dword): string; var i: integer; begin result := ''; for i := 0 to len-1 do result += inttohex(pbyte(p+i)^, 2); end; function tobin(s: string): string; var i: integer; begin result := ''; i := 1; while i < length(s) do begin result += chr(strtoint('$'+copy(s, i, 2))); inc(i, 2); end; end; var s: string; begin with TRegistry.Create do begin RootKey := HKEY_CURRENT_USER; OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent', false); // read //setlength(s, 32); //ReadBinaryData('AccentPalette', s[1], 32); //writeln('palette = ', tohex(@s[1], length(s))); //writeln('StartColorMenu = ', ReadInteger('StartColorMenu')); //writeln('AccentColorMenu = ', ReadInteger('AccentColorMenu')); // apply yellow s := tobin('FFE8A800FFE08C00FFD35C00FFB90000BA890000805E00004D38000000B29400'); WriteBinaryData('AccentPalette', s[1], length(s)); WriteInteger('StartColorMenu', -16741958); WriteInteger('AccentColorMenu', -16729601); // apply green //s := tobin('C1F7DD00A6F7D00068E3A80000CC6A000087460000522A00002B1600E3008C00'); //WriteBinaryData('AccentPalette', s[1], length(s)); //WriteInteger('StartColorMenu', -12155136); //WriteInteger('AccentColorMenu', -9778176); Free; end; end.
Yellow:
https://coolors.co/e8a800-e08c00-d35c00-b90000-890000-5e0000-380000-b29400
I'm sorry but I have quite literally zero idea how to convert a TColor to a binary number that would work with that.
I might be misreading this but it sets the accent color which I may be wrong will only work if you're actually got the accent being set option by the desktop wallaper??