Ver Mensaje Individual
  #2  
Antiguo 14-10-2007
Avatar de aeff
aeff aeff is offline
Miembro
 
Registrado: oct 2006
Ubicación: Cuba, Guantánamo
Posts: 348
Reputación: 20
aeff Va camino a la fama
saludos, no encuentro por ningún lado a mi alrededor la manera de aplicar los cambios realizado a Desktop de la forma que quieres, te propongo una solución:

implementa esto en la unit:

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;

ahora un ejemplo de uso, en el evento onClick de un button pon esto:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  SetDesktopBackground(RGB(40, 110, 112));
end;

bueno, esto es un invento bruto pero al menos simula lo que quieres,

espero que te funcione y te sirva de algo

saludos

aeff!!
Responder Con Cita