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 hWndParent As Long, _ ByVal hWndChild As Long, _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Const GWL_EXSTYLE = (-20) Const WS_EX_TOOLWINDOW = &H80 Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong 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 TCM_FIRST = &H1300 ' Tab control messages Private Const TCM_GETIMAGELIST = (TCM_FIRST + 2) Private Const TCM_SETIMAGELIST = (TCM_FIRST + 3) Private Const TCM_GETITEMCOUNT = (TCM_FIRST + 4) Private Const TCM_GETITEMA = (TCM_FIRST + 5) Private Const TCM_GETITEMW = (TCM_FIRST + 60) Private Const TCM_SETITEMA = (TCM_FIRST + 6) Private Const TCM_SETITEMW = (TCM_FIRST + 61) Private Const TCM_INSERTITEMA = (TCM_FIRST + 7) Private Const TCM_INSERTITEMW = (TCM_FIRST + 62) Private Const TCM_DELETEITEM = (TCM_FIRST + 8) Private Const TCM_DELETEALLITEMS = (TCM_FIRST + 9) Private Const TCM_GETITEMRECT = (TCM_FIRST + 10) Private Const TCM_GETCURSEL = (TCM_FIRST + 11) Private Const TCM_SETCURSEL = (TCM_FIRST + 12) Private Const TCM_HITTEST = (TCM_FIRST + 13) Private Const TCM_SETITEMEXTRA = (TCM_FIRST + 14) Private Const TCM_ADJUSTRECT = (TCM_FIRST + 40) Private Const TCM_SETITEMSIZE = (TCM_FIRST + 41) Private Const TCM_REMOVEIMAGE = (TCM_FIRST + 42) Private Const TCM_SETPADDING = (TCM_FIRST + 43) Private Const TCM_GETROWCOUNT = (TCM_FIRST + 44) Private Const TCM_GETTOOLTIPS = (TCM_FIRST + 45) Private Const TCM_SETTOOLTIPS = (TCM_FIRST + 46) Private Const TCM_GETCURFOCUS = (TCM_FIRST + 47) Private Const TCM_SETCURFOCUS = (TCM_FIRST + 48) Private Const TCM_SETMINTABWIDTH = (TCM_FIRST + 49) Private Const TCM_DESELECTALL = (TCM_FIRST + 50) Private Const TCM_HIGHLIGHTITEM = (TCM_FIRST + 51) Private Const TCM_SETEXTENDEDSTYLE = (TCM_FIRST + 52) Private Const TCM_GETEXTENDEDSTYLE = (TCM_FIRST + 53) Private Const TCM_SETUNICODEFORMAT = &H2005 Private Const TCM_GETUNICODEFORMAT = &H2006 Private Sub Form_Load() Dim lReturn As Long Dim lHwnd As Long lReturn = FindWindow("Shell_TrayWnd", vbNullString) ' 先找 Shell Tray handle lReturn = FindWindowEx(lReturn, 0, "MSTaskSwWClass", vbNullString) ' 再找它的 Child lHwnd = FindWindowEx(lReturn, 0, "SysTabControl32", vbNullString) ' 原来就是这一个 Me.Show 'DoEvents Me.Visible = False '将 Window Extend Style 设成 ToolWindow, 按 Alt-Tab 无法切换到 lReturn = SetWindowLong(Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW) '应该设定 Visible 的属性, 才能让改变Window Style的 API 致能 Me.Visible = True ' 将 SysTab 上的最後一个 Item 删掉 lReturn = SendMessage(lHwnd, TCM_GETITEMCOUNT, 0, ByVal 0) lReturn = SendMessage(lHwnd, TCM_DELETEITEM, lReturn - 1, ByVal 0) End Sub |
本文地址:http://com.8s8s.com/it/it44260.htm