IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API, COM et SDKs Delphi Discussion :

Comment changer l'image Bitmap en fond d'écran du bureau ?


Sujet :

API, COM et SDKs Delphi

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 16
    Points : 14
    Points
    14
    Par défaut Comment changer l'image Bitmap en fond d'écran du bureau ?
    salut,

    Je veux réaliser un petit programme qui puisse modifier le fond d'écran
    J'ai réussie a le faire uniquement avec les .bmp donc ma question est comment afficher les autre extensions?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    SystemParametersInfo(SPI_SETDESKWALLPAPER,0,PChar(Image.text),SPIF_SENDWININICHANGE);
    D'aileurs je voudrais savoir comment les mettre en mosaique, centrer, etirer?

    Merci pour vos reponse.

    PS: J'ai touché aux stratégies (pour ce qui connaissent) j'ai autorisé l'affichage autre que .bmp est cela ne marche toujours pas il affiche l'image dans le "propriétés d'affichage" mais pas sur le bureau!!!

  2. #2
    Membre émérite
    Avatar de Merlin
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mars 2002
    Messages
    524
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information

    Informations forums :
    Inscription : Mars 2002
    Messages : 524
    Points : 2 883
    Points
    2 883
    Par défaut
    Plusieurs moyens sont possibles. Tu peux utiliser :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    procedure ChangeWallpaper(bitmap: string);       {bitmap contains filename: *.bmp}
     
    var pBitmap : pchar;
     
    begin
     bitmap:=bitmap+#0;
     pBitmap:=@bitmap[1];
     SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pBitmap, SPIF_UPDATEINIFILE);
    end;

  3. #3
    Expert éminent sénior

    Avatar de Nono40
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2002
    Messages
    8 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2002
    Messages : 8 640
    Points : 19 104
    Points
    19 104
    Par défaut
    Je croyais que Delphi allouait toujours un octet en plus sur le type String et qu'il était toujours à zéro d'ou le transtypage facile Pchar(VarDeTypeString) ?

    Dans ce cas on peut raccourcir :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    procedure ChangeWallpaper(bitmap: string);       {bitmap contains filename: *.bmp}
    begin
     SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @Bitmap[1], SPIF_UPDATEINIFILE);
    end;

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 16
    Points : 14
    Points
    14
    Par défaut
    cela ne fonctionne pas pour les extensions autre que bmp

  5. #5
    Expert éminent sénior

    Avatar de Nono40
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2002
    Messages
    8 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2002
    Messages : 8 640
    Points : 19 104
    Points
    19 104
    Par défaut
    Oui, car il faut activer ActiveDesktop pour que les autres formats d'images soient supportés.

  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 16
    Points : 14
    Points
    14
    Par défaut
    Mon ActiveDesktop est activé et poutant les autres extensions ne s'affiche pas.
    Mais lorsque j'ouvre la fenetre "propriétés d'affichage" je peux admirer les images qui ne s'affichent pas dans le bureau?!
    meme par avoir rafraicie mon bureau

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 16
    Points : 14
    Points
    14
    Par défaut
    Bonour,
    Alors, personne peut m'aider?

  8. #8
    Membre chevronné
    Avatar de Pierre Castelain
    Inscrit en
    Avril 2002
    Messages
    523
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 523
    Points : 1 943
    Points
    1 943
    Par défaut
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/iactivedesktop/iactivedesktop.asp

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 16
    Points : 14
    Points
    14
    Par défaut
    Allez les jeunes, j'ai trouvé une astuce pour afficher les différentes
    extensions d'images que je voulais pour ce qui sont intéressés:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
     
    procedure TForm1.ChangeWallpaper( Image: string; DisplayStyle : string;
                                       sTile : string);
    var
         reg : TRegistry;
         FileFormat : string[4];
         FichierBMP : string;
    begin
      FileFormat := AnsiUpperCase (ExtractFileExt(Image));
      if ((FileFormat = '.JPG') Or (FileFormat = '.JPE')) then
       begin
         SetLength (FichierBMP,101);
         GetWindowsDirectory (PChar(FichierBMP), 100);
         FichierBMP := string (PChar(FichierBMP));
         FichierBMP := FichierBMP + '\MyWallpaper.bmp';
         ConvertJPG2BMP (Image, FichierBMP); //ici je change mon format
         reg := TRegistry.Create ;
         reg.RootKey := HKEY_CURRENT_USER;
         with reg do
         begin
           try
             if OpenKey ('\Control Panel\Desktop', false) then
              begin
                WriteString ('Wallpaper',FichierBMP);
                WriteString ('WallpaperStyle',DisplayStyle);
                WriteString ('TileWallpaper', sTile);
              end;
           finally
           reg.Free;
           end;
         end;
         SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pChar(FichierBMP), SPIF_UPDATEINIFILE or SPIF_SENDCHANGE);
       end
       else
         if FileFormat = '.BMP' then
          begin
            reg := TRegistry.Create ;
            reg.RootKey := HKEY_CURRENT_USER;
            with reg do
            begin
              try
                if OpenKey ('\Control Panel\Desktop', false) then
                 begin
                   WriteString ('Wallpaper',Image);
                   WriteString ('WallpaperStyle',DisplayStyle);
                   WriteString ('TileWallpaper', sTile);
                 end;
              finally
              reg.Free;
            end;
          end;
          SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pChar(Image),SPIF_UPDATEINIFILE or SPIF_SENDCHANGE); 
       end;
    end;
    merci la FAQ

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. comment changer l'image inseré dans mon crystal reports par code?
    Par rochdi123 dans le forum Windows Forms
    Réponses: 7
    Dernier message: 04/06/2009, 13h52
  2. comment changer l'image de fond d'une cellule par un menu ?
    Par @rno0059 dans le forum Mise en page CSS
    Réponses: 18
    Dernier message: 25/06/2007, 00h06
  3. [VB200]Comment changer les images de plusieurs picturebox
    Par stargates dans le forum Windows Forms
    Réponses: 2
    Dernier message: 14/07/2006, 17h05
  4. Réponses: 1
    Dernier message: 12/05/2006, 09h26
  5. Réponses: 6
    Dernier message: 22/12/2004, 11h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo