1个回答
展开全部
实现这个功能要调用一个API。
然后加载源图到Image控件里面,并保存为BMP图片到硬盘上,再用API设定保存的BMP为桌面背景。
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
Private Const SPI_SETDESKWALLPAPER = 20
Dim WithEvents Image1 As Image
Private Sub Form_Load()
Dim aa As String
aa = "C:\8.jpg" '源图片
With Form1
Set Image1 = .Controls.Add("VB.Image", "Image1", Form1)
.Width = 4000
.Height = 4000
End With
With Form1!Image1
.Visible = True
.Height = 4000
.Width = 4000
.Top = 120
.Left = 120
.Picture = LoadPicture(aa) '加载图片
End With
aa = "C:\MyWallpaper.bmp"
SavePicture Image1, aa '把图片保存到C:\下,命名为M[yWallpaper.bmp]
ChangeWP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, aa, 0) '刷新桌面背景图片
End
End Sub
然后加载源图到Image控件里面,并保存为BMP图片到硬盘上,再用API设定保存的BMP为桌面背景。
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
Private Const SPI_SETDESKWALLPAPER = 20
Dim WithEvents Image1 As Image
Private Sub Form_Load()
Dim aa As String
aa = "C:\8.jpg" '源图片
With Form1
Set Image1 = .Controls.Add("VB.Image", "Image1", Form1)
.Width = 4000
.Height = 4000
End With
With Form1!Image1
.Visible = True
.Height = 4000
.Width = 4000
.Top = 120
.Left = 120
.Picture = LoadPicture(aa) '加载图片
End With
aa = "C:\MyWallpaper.bmp"
SavePicture Image1, aa '把图片保存到C:\下,命名为M[yWallpaper.bmp]
ChangeWP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, aa, 0) '刷新桌面背景图片
End
End Sub
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询