Option Explicit
![]()
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_SHOWWINDOW = &H40
Private Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
![]()
Private Declare Function SetWindowPos()Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
![]()
Private Declare Function FindWindow()Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
![]()
Private Declare Function GetWindow()Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
![]()
Private Declare Function GetClassName()Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
![]()
Private Declare Function SetParent()Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
![]()
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
![]()
Dim hTaskbar As Long, hStartbutton As Long
![]()
![]()
Private Sub cmdHide_Click()Sub cmdHide_Click()
SetWindowPos hTaskbar, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_HIDEWINDOW
End Sub
![]()
![]()
Private Sub cmdHideButton_Click()Sub cmdHideButton_Click()
SetWindowPos hStartbutton, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_HIDEWINDOW
End Sub
![]()
![]()
Private Sub cmdMove_Click()Sub cmdMove_Click()
Static bMove As Boolean
bMove = Not bMove
If bMove Then
SetWindowPos hStartbutton, 0, Screen.Width Screen.TwipsPerPixelX - 100, _
0, 0, 0, SWP_NOSIZE Or SWP_NOZORDER
Else
SetWindowPos hStartbutton, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOZORDER
End If
End Sub
![]()
![]()
Private Sub cmdParent_Click()Sub cmdParent_Click()
SetParent cmdTest.hwnd, hTaskbar
End Sub
![]()
![]()
Private Sub cmdShow_Click()Sub cmdShow_Click()
SetWindowPos hTaskbar, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_SHOWWINDOW
End Sub
![]()
![]()
Private Sub cmdShowButton_Click()Sub cmdShowButton_Click()
SetWindowPos hStartbutton, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_SHOWWINDOW
End Sub
![]()
![]()
Private Sub cmdTest_GotFocus()Sub cmdTest_GotFocus()
Form1.cmdMove.SetFocus
End Sub
![]()
![]()
Private Sub Form_Load()Sub Form_Load()
Dim sClass As String * 250
hTaskbar = FindWindow("Shell_traywnd", vbNullString)
'Search for a child window
hStartbutton = GetWindow(hTaskbar, GW_CHILD)
Do
'get the child window's classname
GetClassName hStartbutton, sClass, 250
'We have the handle of the Start button If the classname is 'button'
If LCase(Left$(sClass, 6)) = "button" Then Exit Do
'Search the next child
hStartbutton = GetWindow(hStartbutton, GW_HWNDNEXT)
Loop
End Sub
![]()
![]()
Private Sub Form_Unload()Sub Form_Unload(Cancel As Integer)
SetWindowPos hStartbutton, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOZORDER
End Sub
![]()