北京朝阳区招聘会:iexplorer窗口被隐藏,用任务管理器才能看到是什么原因?
跑题了,回到题目的问题。
他使用了隐藏IE的任务栏的代码,具体我有段源代码,也具有这个功能Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
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 ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ShowWindowAsync Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare 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 GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As RECT) 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
'Const WM_LBUTTONDOWN = &H201
'Const WM_LBUTTONUP = &H202
'定义窗口以及子窗口的类名
Const sBaseBar = "BaseBar"
Const sTrayWindow = "Shell_TrayWnd"
Const sTrayNotify = "TrayNotifyWnd"
Const sStartButton = "Button"
Const sAppSwitchBar = "ReBarWindow32"
Const sAppSwitch = "MSTaskSwWClass"
Const sAppIcon = "ToolbarWindow32"
Const sTrayClock = "TrayClockWClass"
Const sDesktopIcon = "ShellDll_DefView"
Const sProgman = "Progman"
Const WM_USER = &H400
Const TPM_NONOTIFY = &H80
Const SW_SHOW = 5
Const SW_HIDE = 0
Const SW_NORMAL = 1
Const SW_RESTORE = 9
Const SW_SHOWDEFAULT = 10
Const SW_SHOWNA = 8
Const SW_SHOWNOACTIVATE = 4
Const SWP_ASYNCWINDOWPOS = &H4000
Const HWND_TOP = 0
Const TBM_GETPOS = WM_USER
Dim wnd As Long
Private Sub chkWnd_Click(Index As Integer)
Dim i As Integer
'获得任务栏的窗口句柄
wnd = FindWindow(sTrayWindow, vbNullString)
'Debug.Print Hex(wnd), GetMenu(wnd)
Select Case Index
Case 0
Case 1
'根据任务栏窗口句柄获得子窗口的句柄
wnd = FindWindowEx(wnd, 0, sStartButton, vbNullString)
Case 2
wnd = FindWindowEx(wnd, 0, sTrayNotify, vbNullString)
Case 3
wnd = FindWindowEx(wnd, 0, sAppSwitchBar, vbNullString)
wnd = FindWindowEx(wnd, 0, sAppSwitch, vbNullString)
Case 4
wnd = FindWindowEx(wnd, 0, sTrayNotify, vbNullString)
wnd = FindWindowEx(wnd, 0, sTrayClock, vbNullString)
Case 5
'获取桌面的窗口句柄
wnd = FindWindow(sProgman, vbNullString)
wnd = FindWindowEx(wnd, 0, sDesktopIcon, vbNullString)
Case 6
wnd = FindWindowEx(wnd, 0, sAppSwitchBar, vbNullString)
wnd = FindWindowEx(wnd, 0, sAppIcon, vbNullString)
Case Else
wnd = 0
End Select
If chkWnd(Index).Value = 1 Then
ShowWindow wnd, SW_HIDE
Else
ShowWindow wnd, SW_SHOW
End If
End Sub
Private Sub Command1_Click()
Dim i As Integer
'清除所有的选项并恢复所有窗口
For i = 0 To 6
chkWnd(i).Value = 0
chkWnd_Click (i)
Next i
End Sub
'Private Sub Command2_Click()
' Dim rcL As RECT
' Dim wnd As Long
'
' wnd = FindWindow(sBaseBar, vbNullString)
' Debug.Print Hex(wnd)
' 'Debug.Print TrackPopupMenu(wnd, TPM_NONOTIFY, 100, 100, 0, 0, rcL)
' Debug.Print GetMenu(wnd)
' 'Debug.Print SendMessage(wnd, TBM_GETPOS, 0, 0)
' 'GetWindowRect wnd, rcL
' 'Debug.Print SetWindowPos(wnd, HWND_TOP, 100, 200, 200, 350, SWP_ASYNCWINDOWPOS)
' 'Debug.Print wnd, rcL.Left, rcL.Right, rcL.Top, rcL.Bottom
' 'Debug.Print ShowWindowAsync(wnd, SW_SHOW)
'End Sub
Private Sub Form_Load()
chkWnd(0).Caption = "隐藏任务栏"
chkWnd(1).Caption = "隐藏开始按钮"
chkWnd(2).Caption = "隐藏任务栏图标"
chkWnd(3).Caption = "隐藏程序按钮"
chkWnd(4).Caption = "隐藏任务栏时钟"
chkWnd(5).Caption = "隐藏桌面图标"
chkWnd(6).Caption = "隐藏快速运行图标"
Command1.Caption = "恢复所有窗口"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Command1_Click
End Sub
不知道能不能对你所帮助,呵呵!!