'This project needs '- a common dialog box ' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T) ' and select Microsoft Common Dialog control) '- a button
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Const SPI_SETDESKWALLPAPER = 20 Const SPIF_UPDATEINIFILE = &H1 Const SPIF_SENDWININICHANGE = &H2
Private Sub Command1_Click() 'Set the commondialogbox' title CDBox.DialogTitle = "Choose a bitmap" 'Set the filter CDBox.Filter = "Windows Bitmaps (*.BMP)|*.bmp|All Files (*.*)|*.*" 'Show the 'Open File'-dialog CDBox.ShowOpen 'Change the desktop's background SystemParametersInfo SPI_SETDESKWALLPAPER, 0, CDBox.filename, SPIF_UPDATEINIFILE End Sub
Private Sub Form_Load() Command1.Caption = "Set Wallpaper" End Sub
bon c'est un exemple, le principal c'est d'avoir un fichier BMP avec son chemin complet, et de faire: SystemParametersInfo 20, 0&, ByVal nameFile, &H2 Or &H1
|