Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Invento para cambiar el color-background del Desktop (https://www.clubdelphi.com/foros/showthread.php?t=80842)

aeff 14-10-2007 18:43:57

Invento para cambiar el color-background del Desktop
 
Bueno, esto es realmente un invento pero simula el proceso original, je je je!!


Código Delphi [-]
...
  uses ShlObj, ActiveX, ComObj, Registry;
...

procedure SetDesktopBackground(Color: TColor);
var
  tmpFile: array[0..MAX_PATH] of Char;
  rValue, gValue, bValue, fName: string;
  Bmp: TBitmap;
  Reg: TRegistry;
  shDesk: IActiveDesktop;
  vWallPOp: TWallPaperOpt;
begin
  //
  GetEnvironmentVariable('TEMP', tmpFile, MAX_PATH);
  fName :=  string (tmpFile) + '\dbg.bmp';
  //
  rValue := IntToStr(GetRValue(Color));
  gValue := IntToStr(GetGValue(Color));
  bValue := IntToStr(GetBValue(Color));
  Bmp := TBitmap.Create;
  Bmp.Width := 1;
  Bmp.Height := 1;
  Bmp.Canvas.Pixels[0,0] := Color;
  Bmp.SaveToFile(fName);
  Bmp.Free;
  //
  Reg := TRegistry.Create;
  Reg.OpenKey('\Control Panel\Colors\', false);
  Reg.WriteString('Background',rValue + ' ' + gValue + ' ' + bValue);
  Reg.Free;
  //
  shDesk := (CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop);
  shDesk.SetWallpaper(StringToOleStr(fName), 0);
  vWallPOp.dwSize := Sizeof(TWallPaperOpt);
  vWallPOp.dwStyle := WPSTYLE_TILE;
  shDesk.SetWallpaperOptions(vWallPOp, 0);
  shDesk.ApplyChanges(AD_APPLY_ALL or AD_APPLY_FORCE);
  shDesk.SetWallpaper('', 0);
  DeleteFile(fName);
  //
  FreeObjectInstance(Pointer(shDesk));
end;

un ejmplo de llamada
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  SetDesktopBackground(RGB(40, 110, 112));
end;




La franja horaria es GMT +2. Ahora son las 10:45:01.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi