wallpaper.frm

来自「大量优秀的vb编程」· FRM 代码 · 共 119 行

FRM
119
字号
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "设置墙纸"
   ClientHeight    =   5304
   ClientLeft      =   48
   ClientTop       =   336
   ClientWidth     =   5100
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5304
   ScaleWidth      =   5100
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command4 
      Caption         =   "打开图像文件"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.8
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   600
      TabIndex        =   3
      Top             =   3840
      Width           =   1575
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退出程序"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.8
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1560
      TabIndex        =   2
      Top             =   4560
      Width           =   1335
   End
   Begin VB.PictureBox Picture1 
      Height          =   3495
      Left            =   240
      ScaleHeight     =   3444
      ScaleWidth      =   4524
      TabIndex        =   1
      Top             =   120
      Width           =   4575
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   4320
      Top             =   1320
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command1 
      Caption         =   "设置墙纸"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.8
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   2520
      TabIndex        =   0
      Top             =   3840
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_UPDATEINIFILE = &H1

Dim Wallpaper As String
Private Sub Command1_Click()
Dim t As Long


If Wallpaper = "" Then Exit Sub
  t = SystemParametersInfo(ByVal SPI_SETDESKWALLPAPER, True, ByVal Wallpaper, SPIF_UPDATEINIFILE)
If t = 0 Then
    MousePointer = 0
    MsgBox "Error changing wallpaper"
    Exit Sub
End If

End Sub
Private Sub Command3_Click()
End
End Sub

Private Sub Command4_Click()
CommonDialog1.Filter = "BMP文件(*.BMP)|*.BMP"
CommonDialog1.ShowOpen
Wallpaper = CommonDialog1.FileName
Picture1.Picture = LoadPicture(Wallpaper)
 Command1.Enabled = True
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?