📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "修改桌面图标的背景"
ClientHeight = 1545
ClientLeft = 60
ClientTop = 345
ClientWidth = 4020
LinkTopic = "Form1"
ScaleHeight = 1545
ScaleWidth = 4020
StartUpPosition = 1 '所有者中心
Begin MSComDlg.CommonDialog Dialog1
Left = 0
Top = 135
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command3
BackColor = &H00FFC0C0&
Caption = "退出"
Height = 375
Left = 900
Style = 1 'Graphical
TabIndex = 2
Top = 1080
Width = 2070
End
Begin VB.CommandButton Command2
BackColor = &H00FFC0C0&
Caption = "修改背景颜色"
Height = 375
Left = 900
Style = 1 'Graphical
TabIndex = 1
Top = 585
Width = 2070
End
Begin VB.CommandButton Command1
BackColor = &H00FFC0C0&
Caption = "设置背景透明"
Height = 375
Left = 900
Style = 1 'Graphical
TabIndex = 0
Top = 90
Width = 2070
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName _
As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 _
As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, ByVal lpRect _
As Long, ByVal bErase As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LVM_SETTEXTBKCOLOR = &H1000 + 38
Dim Parent&, Child&, CChild&
Private Sub Command1_Click()
'获取桌面的句柄
Parent = FindWindow(vbNullString, "Program Manager")
Child = FindWindowEx(Parent, 0, "SHELLDLL_DefView", vbNullString)
'获取桌面图标的句柄
CChild = FindWindowEx(Child, 0, "SysListView32", vbNullString)
'设置桌面图标背景为透明
SendMessage CChild, LVM_SETTEXTBKCOLOR, 0, ByVal &HFFFFFFFF
InvalidateRect CChild, 0, True
End Sub
Private Sub Command2_Click()
Dialog1.ShowColor
'获取桌面的句柄
Parent = FindWindow(vbNullString, "Program Manager")
Child = FindWindowEx(Parent, 0, "SHELLDLL_DefView", vbNullString)
'获取桌面图标的句柄
CChild = FindWindowEx(Child, 0, "SysListView32", vbNullString)
'设置桌面图标背景颜色等于对话框中的颜色
SendMessage CChild, LVM_SETTEXTBKCOLOR, 0, ByVal Dialog1.Color
InvalidateRect CChild, 0, True
End Sub
Private Sub Command3_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -