Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 30-09-2004
bustio bustio is offline
Miembro
 
Registrado: oct 2003
Posts: 231
Poder: 21
bustio Va por buen camino
Cambiar mi Wallpaper en RUntime

HOla!!! Necesito saber como hacer para que mi aplicacion Delphi cambie el Tapiz del Desktop por codigo y en RUntime. El ejemplo que esta en un hilo del foro no hace nada..... Trabajo sobre Win2003Server. No creo que el So sea la causa de que no funcione, pero bueno.

EN si lo que necesito es saber que hacer para que en una direccion donde esta el Jpg que quiero poner de fondo, al pasarsela a una determinada funcion(que es la que cambia el Wallpaper) ponga el JPG que esta en esa direccion de tapiz.

GRACIAS!!!!!
Responder Con Cita
  #2  
Antiguo 30-09-2004
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.281
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por bustio
...que mi aplicacion Delphi cambie el Tapiz del Desktop por codigo y en RUntime. El ejemplo que esta en un hilo del foro no hace nada....
Supongo que debe ser para versiones anteriores de Windows; Prueba con éste código:

Código Delphi [-]
var
  ActiveDesktop: IActiveDesktop;
begin
  ActiveDesktop := CreateComObject(CLSID_ActiveDesktop)
    as IActiveDesktop;
  ActiveDesktop.SetWallpaper('c:\winnt\Azteca.bmp', 0);
  ActiveDesktop.ApplyChanges(AD_APPLY_ALL or AD_APPLY_FORCE);

Deberás añadir al uses: ComObj y ShlObj
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #3  
Antiguo 30-09-2004
bustio bustio is offline
Miembro
 
Registrado: oct 2003
Posts: 231
Poder: 21
bustio Va por buen camino
Cambiar el Walpaper en RunTime

ActiveDesktop.SetWallpaper('c:\winnt\Azteca.bmp', 0);

La funcion que me diste cambia mi Tapiz de maravillas!!! Siempre que se le pase como parametros una direccion propiamente dicha. Muchas gracias!!! Ahora el detalle esta en que esa direccion debe ser un PWideChar, no un string o un TCaption. Ahora necesito saber que hacer para que esta funcion soporte un String.. Probe con hacerle un casting a mi direccion string(PWideChar(Address)) pero no funciona. Me pudieran ayudar ahora con esta nueva incognita?

GRACIAS
Responder Con Cita
  #4  
Antiguo 01-10-2004
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.281
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
¿Has probado PChar(Str)?
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #5  
Antiguo 01-10-2004
bustio bustio is offline
Miembro
 
Registrado: oct 2003
Posts: 231
Poder: 21
bustio Va por buen camino
Respondiendo a mi mismo

Hola Comunidad!!!

Despues de analizar mi problema para cambiar un desktop en RunTime programe esto: aqui les mandoe lcodigo.. espero que les sea util
GRACIAS!!


procedure TfrmPrincipal.CabiarWallpaper;
var
Tapiz, Addr: String;
Cant : Integer;
Num : Integer;

ActiveDesktop : IActiveDesktop;
Buffer : Array [0..1000]of WideChar;
Direccion : PWideChar;

begin
Cant := ListaFicheros.Items.Count;
If Aleatorio = False then
begin
inc(TapizActual);
Try
Tapiz := ListaFicheros.Items.Item[TapizActual].Caption;
Addr := edtCamino.Text + '\' + Tapiz;
ActiveDesktop := CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
Direccion:= StringToWideChar(Addr,Buffer,Length(Addr)+1);
ActiveDesktop.SetWallpaper(Direccion,0);
ActiveDesktop.ApplyChanges(AD_APPLY_ALL or AD_APPLY_FORCE);
Except
End;
end
else
begin
Randomize;
Num := Random(Cant -1);
While ((Num) > Cant) or ((Num) < 0) do
begin
Num := Random(Cant -1);
end;
Try
Tapiz := ListaFicheros.Items.Item[Num].Caption;
Addr := edtCamino.Text + '\' + Tapiz;
ActiveDesktop := CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
Direccion:= StringToWideChar(Addr,Buffer,Length(Addr)+1);
ActiveDesktop.SetWallpaper(Direccion,0);
ActiveDesktop.ApplyChanges(AD_APPLY_ALL or AD_APPLY_FORCE);
Except
End;
end;
end;
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 00:00:00.


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
Copyright 1996-2007 Club Delphi