Les Snippets

Connexion

Modifier le fond d'écran de votre bureau windows

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 27/07/2006 20:40:46 et initié par romagny13 [Liste]
Date de mise à jour : 09/04/2007 12:33:26
Vue : 21283
Catégorie(s) : Divers, Graphique
Langages dispo pour ce code :
- C# 2.x
- VB 2005
- mIRC
- Delphi 5
- Delphi 5



Langage : C# 2.x
Date ajout : 27/07/2006
Posté par romagny13 [Liste]
DateMAJ : 28/07/2006
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)] 
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
private void definir_arriere_plan_bureau() 
{
    OpenFileDialog odlg = new OpenFileDialog(); 
    odlg.Filter = "Images Bitmap (*.bmp,*.BMP)|*.BMP;*.BMP";
    if (odlg.ShowDialog()==DialogResult.OK) 
    {
        string filename = odlg.FileName; 
        string subname;
        if (filename.Length > 3) 
        {

            subname = filename.Substring(filename.Length - 3, 3);
            if (subname == "bmp" || subname == "BMP") 
            {

                SystemParametersInfo(20, 0, filename, 0x1 | 0x2);

                //MessageBox.Show("L'image définie est désormais ","Bureau modifié"+System.Environment.UserDomainName);

            }

            else

            {

                //MessageBox.Show("selectionner une image bitmap (.BMP) ","Attention..."); End If

            }

        }

    }

}


Remarque :
il suffit alors d'appeler la procédure definir_arriere_plan_bureau()
depuis l'evênement clic sur un bouton par exemple

ne marche qu'avec bitmaps actuellement.
Langage : VB 2005
Date ajout : 28/07/2006
Posté par romagny13 [Liste]
<Runtime.InteropServices.DllImport("user32.dll", CharSet:=Runtime.InteropServices.CharSet.Auto)> _ 
Public Shared Function SystemParametersInfo(ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer

End Function


Public Sub definir_arriere_plan_bureau() 
    Dim odlg As New OpenFileDialog 
    odlg.Filter = "Images Bitmap (*.bmp,*.BMP)|*.BMP;*.BMP"

    If odlg.ShowDialog = Windows.Forms.DialogResult.OK Then 
        Dim filename As String = odlg.FileName 
        Dim subname As String

        If filename.Length > 3 Then

            subname = filename.Substring(filename.Length - 3, 3)

            If subname = "bmp" OrElse subname = "BMP" Then
                SystemParametersInfo(20, 0, filename, 1 Or 2) 
                'MessageBox.Show("L'image définie est désormais ","Bureau modifié"+System.Environment.UserDomainName);

            Else

                'MessageBox.Show("selectionner une image bitmap (.BMP) ","Attention..."); End If

            End If

        End If

End Sub

Langage : mIRC
Date ajout : 14/09/2006
Posté par dj328i [Liste]
; On crée l'alias
alias wallchange {
; On vérifie l'existance des paramètres 
if (!$exists($1) || !$2) { Echo -a Erreur de paramètre | halt }
; On change les valeur directement dans le registre 
run cmd /c reg add HKCU\Control Panel\Desktop /v wallpaper /d "CHEMINDELIMAGEICI" /f run cmd /c reg add HKCU\Control Panel\Desktop /v wallpaperStyle /d $iif($2 == etirer,2,$iif($2 == centrer,0,1)) /f 
; On rafraichie le bureau
run Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True }
Version sans commentaire : 
alias wallchange {
if (!$exists($1) || !$2) { Echo -a Erreur de paramètre | halt }
run cmd /c reg add HKCU\Control Panel\Desktop /v wallpaper /d "CHEMINDELIMAGEICI" /f
 run cmd /c reg add HKCU\Control Panel\Desktop /v wallpaperStyle /d $iif($2 == etirer,2,$iif($2 == centrer,0,1)) /f 
run Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True }

Remarque :
Ce snipper ne fonctionne qu'avec Windows XP , a confirmé pour Vista. Aussi disponible pour plate-forme 9x sous demande.
Langage : Delphi 5
Date ajout : 07/10/2006
Posté par cirec [Liste]
procedure TfrmMain.Button1Click(Sender: TObject);
begin
  With TOpenPictureDialog.Create(Self) do
    Try
      InitialDir := '%USERPROFILE%';
      Filter := GraphicFilter(TBitmap);
      If Execute Then
        SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, PChar(FileName), SPIF_SENDCHANGE);
    Finally
      Free;
    End;
end;

Remarque :
Ne pas oublier de déclarer ExtDlgs dans la clause Uses pour l'utilisation de TOpenPictureDialog
Langage : Delphi 5
Date ajout : 09/04/2007
Posté par japee [Liste]
DateMAJ : 09/04/2007
uses ShlObj, ComObj, Jpeg;
procedure ApplyWallPaper(const FileName: string; wpStyle: DWORD = WPSTYLE_CENTER);
const
  GUID: TGUID = '{75048700-EF1F-11D0-9888-006097DEACF9}';
var
  ComObj       : IUnknown;
  Buffer       : PWideChar;
  WallPaperOpt : TWallPaperOpt;
begin
  if not FileExists(FileName) then Exit;
  Buffer := AllocMem(MAX_PATH);
  StringToWideChar(FileName, Buffer, MAX_PATH);
  WallPaperOpt.dwStyle := wpStyle;
  WallPaperOpt.dwSize := SizeOf(WallPaperOpt);
  ComObj := CreateComObject(GUID);
  with ComObj as IActiveDesktop do
  begin
    SetWallpaperOptions(WallPaperOpt, 0);
    SetWallpaper(Buffer, 0);
    ApplyChanges(AD_APPLY_ALL); //(AD_APPLY_ALL or AD_APPLY_FORCE);
  end;
  FreeMem(Buffer);
end;
Remarque :
Cette fonction permet d'appliquer comme papier-peint du bureau tous les formats
graphiques autorisés (bmp, jpg, gif...), mais également une page au format htlm.
Sous XP, il n'est pas besoin d'avoir installé Active Desktop.

Les paramètre wpStyle sont :
  WPSTYLE_CENTER  = 0;
  WPSTYLE_TILE    = 1;
  WPSTYLE_STRETCH = 2;
  WPSTYLE_MAX     = 3;

Inutile de les déclarer car ils sont présents dans l'unité ShlObj.
Par contre, ne pas oublier ShlObj, ComObj, Jpeg dans les uses.

Exemple d'utilisation avec un OpenDialog et un RadioGroup :

procedure TForm1.btnOpenClick(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    ApplyWallPaper(OpenDialog1.FileName, rgStyle.ItemIndex);
  end;
end;

Snippets en rapport avec : Image, Écran, Bureau, Wallpaper, Fond



Codes sources en rapport avec : Image, Écran, Bureau, Wallpaper, Fond

{Visual Basic, VB6, VB.NET, VB 2005} MODIFICATION DU PAPIER PEINT/FOND D'ÉCRAN DU BUREAU
Ce code sert simplement à modifier le fond d'écran de votre bureau. ...

{Visual Basic, VB6, VB.NET, VB 2005} MFE : MODIFICATEUR DE FOND D'ECRAN AUTOMATIQUE
C'est un programme très sympa qui change le fond d'écran automatiquement à chaque démarrage, tous le...

{Delphi} WALLPAPERCAM
Insertion capture webcam sur le papier peint du bureau ou remplacement du papier peint par la captur...

{Visual Basic, VB6, VB.NET, VB 2005} FROSTDESKTOP 2007 - DES ÉCRANS VIRTUELS À LA LINUX
Bonjour à tous, je poste ici ma première source sur VBFrance.com. Il sagit d'un logiciel qui permet...

{Delphi} WALLPAPER - CHANGEMENT AUTOMATIQUE DU FOND D'ECRAN
Permet de modifier votre fond d'écran aléatoirement...

{C / C++ / C++.NET} DESSIN SUR ÉCRAN (TRÈS SIMPLE)
Source en C, fonctionne tel quel en C++. Uitlise l'API Windows. Mis à jour (1.0.1). Merci vecchio56...

{Delphi} TRANSPARENCE DANS LA FORM (TROUS)
Voici une source permetant de voir comment faire un trou dans une form et (sur la form2) la transpar...

{Visual Basic, VB6, VB.NET, VB 2005} EASY WALLPAPER
c'est un programme qui change votre fon d'ecran tout simplement...

{IRC} WALLPAPERS POUR VOTRE BUREAU
N'ayant plus d'idées de scripts à développer voici la seule chose que j'ai trouvé à faire : Cet a...

{Visual Basic, VB6, VB.NET, VB 2005} CHANGEZ SON WALLPAPER SIMPLEMENT.
Ce code n'est pas entierement de moi, je l'ai adapter pour l'utiliser plus facilement, ce code perme...