SetWindowPos Me.hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
这样? 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 SetParent Lib "user32" (ByVal hWndChild As _ Long, ByVal hWndNewParent As Long) As LongPrivate Sub Form_Load() Dim hWindow As Long
楼上的方法不行的,至少在XP是不行的,如果你的方法可以,这样就更简单Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long Private Sub Form_Load() SetParent Me.hWnd, GetDesktopWindow '其实这样写更简单 SetParent Me.hWnd, 0 End Sub但是这样直接把窗口放入桌面成为子窗口也是不行的,如果把控件指定到桌面那到可以,如: Dim MovX As Long, MovY As Long Private Sub Form_Load() SetParent Picture1.hWnd, GetDesktopWindow End Sub '以下代码可托动控件 Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button = 1 Then MovX = X: MovY = Y End If End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button = 1 Then Picture1.Move Picture1.Left + (X - MovX), Picture1.Top + (Y - MovY) End If End Sub
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 SetParent Lib "user32" (ByVal hWndChild As _
Long, ByVal hWndNewParent As Long) As LongPrivate Sub Form_Load()
Dim hWindow As Long
hWindow = FindWindow("Progman", "Program Manager")
hWindow = FindWindowEx(hWindow, 0, "SHELLDLL_DefView", "")
hWindow = FindWindowEx(hWindow, 0, "SysListView32", "")
Call SetParent(Me.hWnd, hWindow)
End Sub
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Sub Form_Load()
SetParent Me.hWnd, GetDesktopWindow
'其实这样写更简单 SetParent Me.hWnd, 0
End Sub但是这样直接把窗口放入桌面成为子窗口也是不行的,如果把控件指定到桌面那到可以,如:
Dim MovX As Long, MovY As Long
Private Sub Form_Load()
SetParent Picture1.hWnd, GetDesktopWindow
End Sub
'以下代码可托动控件
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
If Button = 1 Then
MovX = X: MovY = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
If Button = 1 Then
Picture1.Move Picture1.Left + (X - MovX), Picture1.Top + (Y - MovY)
End If
End Sub