*提取桌面背景图片到FORM窗体:
Private Declare Function PaintDesktop Lib “user32” (ByVal hdc As Long) As Long
Private Sub Form_Paint()
PaintDesktop Me.hdc
End Sub
*鼠标穿透FORM窗体
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Const WS_EX_TRANSPARENT As Long = &H20&
Private Declare Function GetWindowLong Lib “user32” Alias “GetWindowLongA” (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib “user32” Alias “SetWindowLongA” (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Sub Fme(S As Boolean)
If S = True Then
SetWindowLong Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED Or WS_EX_TRANSPARENT '鼠标穿透窗体
Else
SetWindowLong Me.hwnd, GWL_EXSTYLE, 0 '取消鼠标穿透窗体
End If
End Sub
*刷新桌面
Private Declare Function PostMessage Lib “user32” Alias “PostMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) 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
Const WM_KEYDOWN = &H100
Private Sub RefreshDesktop()
Dim DesWin As Long
DesWin = FindWindowEx(0&, 0&, “Progman”, vbNullString)
'DesWin = FindWindowEx(DesWin, 0&, “SHELLDLL_DefView”, vbNullString)
'DesWin = FindWindowEx(DesWin, 0&, “SysListVietw32”, vbNullString)
PostMessage DesWin, WM_KEYDOWN, &H74, &H3F0001
End Sub
*隐藏、显示桌面图标
Private Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib “user32” (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_HIDE = 0
Const SW_RESTORE = 9
Private Sub Command1_Click() '隐藏
Dim Hwd As Long
Dim rtn As Long
Hwd = FindWindow(“progman”, vbNullString)
rtn = ShowWindow(Hwd, SW_HIDE)
End Sub
Private Sub Command2_Click() '显示
Dim Hwd As Long
Dim rtn As Long
Hwd = FindWindow(“progman”, vbNullString)
rtn = ShowWindow(Hwd, SW_RESTORE)
End Sub
*显示桌面(把所有的窗口最小化)
Private Sub Command1_Click()
CreateObject(“Shell.Application”).ToggleDesktop
End Sub
'将窗体嵌入桌面
Private Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib “user32” (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Dim i&
i = FindWindow(“progman”, vbNullString)
SetParent Me.hwnd, i
End Sub
Private Sub Command2_Click()
SetParent Me.hwnd, 0
End Sub