Page 1 sur 1

Changer le fond d'écran

Publié : jeu. 29/janv./2004 10:54
par Le Soldat Inconnu
attention, qu'il n'y ait pas un petit malin qui s'avise de faire la même chose que mon changeur de fond d'écran :x

mais non, je plaisante :wink:

Code : Tout sélectionner

Procedure SetWallpaper(FileName.s, Style.s)
  ; style = 0 : centrer
  ; style = 2 : étirer
  RegOpenKeyEx_(#HKEY_CURRENT_USER, "Control Panel\Desktop\", #NULL, #KEY_ALL_ACCESS, @hKey)
  RegSetValueEx_(hKey, "WallpaperStyle", #NULL, #REG_SZ, @Style, Len(Style) + 1 )
  Style = "0"
  RegSetValueEx_(hKey, "TileWallpaper", #NULL, #REG_SZ, @Style, Len(Style) + 1 )
  SystemParametersInfo_(#SPI_SETDESKWALLPAPER, 0, FileName, #SPIF_UPDATEINIFILE | #SPIF_SENDWININICHANGE)
EndProcedure

WPFileName.s = OpenFileRequester("Choix de l'image BMP", "*.bmp", "Bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*", 1, 0)
If WPFileName <> ""
  SetWallpaper(WPFileName, "2")
EndIf

Publié : mar. 06/juin/2006 20:40
par graph100
Ton truc ne marche pas avec les jpg :(

Re: Changer le fond d'écran

Publié : mar. 06/juin/2006 21:14
par AWEAR
Le Soldat Inconnu a écrit :attention, qu'il n'y ait pas un petit malin qui s'avise de faire la même chose que mon changeur de fond d'écran :x
Je me sens visé, alors je te présente mes excuses pour mon poste sur l'autre topic..

Sinon graph100 c'est normal, c'est l'API elle-même qui empêche l'utilisation d'une image autre qu'un bitmap..

Publié : mer. 07/juin/2006 12:41
par graph100
pourtant on peut mettre une jpg en fond d'ecran !!

Publié : mer. 07/juin/2006 13:38
par AWEAR
Sauf erreur de ma part, Windows enregistre ton image quelque part avant de la mettre en fond d'écran.

Publié : ven. 09/juin/2006 9:43
par Gillou
La même chose avec possibilité de choisir une image jpeg, bmp,..
ProcedureDLL.s GetUserProfileDirectory() ; Retourne l'adresse du répertoire utilisateur
     OpenProcessToken_ ( GetCurrentProcess_ (), $08, @token)
    
    Length.l = 512
    directory$ = Space (Length)
    
     GetUserProfileDirectory_ (token, directory$, @Length)
     ProcedureReturn Left (directory$, Length) + "\"
EndProcedure

ProcedureDLL.s GetWindowsDirectory_BIS() ; Retourne l'adresse de Windows
    windir$ = Space (255) : GetWindowsDirectory_ ( @windir$, 255) : If Right (windir$, 1) <> "\" : windir$ + "\" : EndIf
     ProcedureReturn windir$
EndProcedure

ProcedureDLL SetWallpaper(FileName.s, Image, mode.l, BackgroundColor.l) ; mode=1 Etirer, 2 Centrer, 3 Centrer et agrandir, 4 Mosaïque, 5 Mosaïque et agrandi (si FileName="" , Image sera pris en compte et inversement)
     ; mode=1 Etirer
     ; mode=2 Centrer
     ; mode=3 Centrer et agrandissement proportionnel
     ; mode=4 Mosaïque
     ; mode=5 Mosaïque et agrandissement proportionel
     If FileName
         UseJPEGImageDecoder ()
; UseEC_OLEImageDecoder()
         UsePNGImageDecoder ()
         UseTGAImageDecoder ()
         UseTIFFImageDecoder ()
        idi = LoadImage ( #PB_Any , FileName)
     ElseIf Image
        idi = Image
     EndIf
    
     If IsImage (idi)
        id = ImageID (idi)
        largimag = ImageWidth (idi)
        hautimag = ImageHeight (idi)
        dx = GetSystemMetrics_ ( #SM_CXSCREEN )
        dy = GetSystemMetrics_ ( #SM_CYSCREEN )
        lon = Len ( GetExtensionPart (FileName))
         If IsAdmin() = 1
             If OSVersion () = #PB_OS_Windows_XP Or OSVersion () = #PB_OS_Windows_2000
                photo.s = GetWindowsDirectory_BIS() + "Web\Wallpaper\Fond d'écran.bmp"
             Else
                photo.s = GetWindowsDirectory_BIS() + "Fond d'écran.bmp"
             EndIf
         Else
            photo.s = GetUserProfileDirectory() + "Fond d'écran.bmp"
         EndIf
         If mode = 1
             ResizeImage (idi, dx, dy)
             SaveImage (idi, photo)
         ElseIf mode = 2
            idi2 = CreateImage ( #PB_Any , dx, dy)
             StartDrawing ( ImageOutput (idi2))
                 Box (0, 0, dx, dy, BackgroundColor)
                 DrawImage (Id, (dx - largimag) / 2, (dy - hautimag) / 2)
             StopDrawing ()
             SaveImage (idi2, photo)
         ElseIf mode = 3
            idi2 = CreateImage ( #PB_Any , dx, dy)
             StartDrawing ( ImageOutput (idi2))
                 Box (0, 0, dx, dy, BackgroundColor)
                clarg.f = dx / largimag
                chaut.f = dy / hautimag
                 If clarg > chaut
                     DrawImage (Id, (dx - Round (chaut * largimag, 0)) / 2, 0, Round (chaut * largimag, 0), dy)
                 ElseIf clarg < chaut
                     DrawImage (Id, 0, (dy - Round (clarg * hautimag, 0)) / 2, dx, Round (clarg * hautimag, 0))
                 Else
                     DrawImage (id, 0, 0, dx, dy)
                 EndIf
             StopDrawing ()
             SaveImage (idi2, photo)
             FreeImage (idi2)
         ElseIf mode = 4
            idi2 = CreateImage ( #PB_Any , dx, dy)
             StartDrawing ( ImageOutput (idi2))
                 Box (0, 0, dx, dy, BackgroundColor)
                nc = Round (dx / largimag, 1)
                nl = Round (dy / hautimag, 1)
                 For a = 0 To nc - 1
                     For b = 0 To nl - 1
                         DrawImage (id, a * largimag, b * hautimag)
                     Next
                 Next
             StopDrawing ()
             SaveImage (idi2, photo)
             FreeImage (idi2)
         ElseIf mode = 5
            idi2 = CreateImage ( #PB_Any , dx, dy)
             StartDrawing ( ImageOutput (idi2))
                 Box (0, 0, dx, dy, BackgroundColor)
                clarg.f = dx / largimag
                chaut.f = dy / hautimag
                 If clarg > chaut
                    width = Round (chaut * largimag, 0)
                    height = dy
                 ElseIf clarg < chaut
                    width = dx
                    height = Round (clarg * hautimag, 0)
                 Else
                    width = dx
                    height = dy
                 EndIf
                nc = Round (dx / width, 1)
                nl = Round (dy / height, 1)
                 For a = 0 To nc - 1
                     For b = 0 To nl - 1
                         DrawImage (id, a * width, b * Height, width, height)
                     Next
                 Next
             StopDrawing ()
             SaveImage (idi2, photo)
             FreeImage (idi2)
         EndIf
         If FileName
             FreeImage (idi)
         EndIf
         ProcedureReturn SystemParametersInfo_ ( #SPI_SETDESKWALLPAPER , 0, photo, #SPIF_UPDATEINIFILE | #SPIF_SENDWININICHANGE )
     EndIf
EndProcedure

Publié : jeu. 13/août/2009 20:54
par Backup
@ soldat inconnu

je viens de telecharger ton changeur de fond d'ecran

j'ai une petite demande

pourrai tu inclure la possibilité de choisir le temps de changement

par exemple changement toute les minutes, ou 30 secondes ou 1 heures ect !! , bref ajouter un chrono :)

j'ai noté un bug chez moi

lorsque je cherche a faire afficher en mode "etiré" a partir de ton soft
j'ai un plantage du soft ! (XP etait lui reglé sur "Centré")

j'ai finalement pu faire afficher en mode étiré en passant par XP
pas par ton soft :)

sinon sympath ce soft :)

Publié : jeu. 13/août/2009 22:30
par lionel_om

Publié : sam. 15/août/2009 15:19
par Le Soldat Inconnu
Mon, logiciel, c'est juste au démarrage pour ne bouffer aucune ressource :)

Publié : sam. 15/août/2009 16:05
par Thyphoon
Le Soldat Inconnu a écrit :Mon, logiciel, c'est juste au démarrage pour ne bouffer aucune ressource :)
sinon il suffit de faire une tache planifier qui execute le logiciel tout les x... minutes ... :)

Publié : sam. 15/août/2009 16:56
par Le Soldat Inconnu
Oui aussi, mais bon, je ne l'utilise plus, ce logiciel, donc il n'évolue plus.

Et je suis assez occupée en programmation pour le moment, avec un gros projet pour remplacer mon PopupMenu Editeur