LeNgHoSt's Blog

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
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 Lib "user32" (ByVal hwnd As LongByVal hWndInsertAfter As LongByVal x As LongByVal y As LongByVal cx As LongByVal cy As LongByVal wFlags As LongAs Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As StringByVal lpWindowName As StringAs Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As LongByVal wCmd As LongAs Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As LongByVal lpClassName As StringByVal nMaxCount As LongAs Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As LongByVal hWndNewParent As LongAs 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()
SetWindowPos hTaskbar, 
00000, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_HIDEWINDOW
End Sub


Private Sub cmdHideButton_Click()
SetWindowPos hStartbutton, 
00000, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_HIDEWINDOW
End Sub


Private Sub cmdMove_Click()
Static bMove As Boolean
bMove 
= Not bMove
If bMove Then
    SetWindowPos hStartbutton, 
0, Screen.Width  Screen.TwipsPerPixelX - 100, _
        
000, SWP_NOSIZE Or SWP_NOZORDER
Else
    SetWindowPos hStartbutton, 
00000, SWP_NOSIZE Or SWP_NOZORDER
End If
End Sub


Private Sub cmdParent_Click()
SetParent cmdTest.hwnd, hTaskbar
End Sub


Private Sub cmdShow_Click()
SetWindowPos hTaskbar, 
00000, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_SHOWWINDOW
End Sub


Private Sub cmdShowButton_Click()
SetWindowPos hStartbutton, 
00000, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_SHOWWINDOW
End Sub


Private Sub cmdTest_GotFocus()
Form1.cmdMove.SetFocus
End Sub


Private 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(Cancel As Integer)
SetWindowPos hStartbutton, 
00000, SWP_NOSIZE Or SWP_NOZORDER
End Sub

posted on 2004-08-17 12:25  LeNgHoSt  阅读(1217)  评论(0)    收藏  举报