'在窗体中加一timer控件;试一试OK? Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As LongPrivate Type POINTAPI x As Long y As Long End TypePrivate Const SW_HIDE = 0 Private Sub Timer1_Timer() Dim Z As POINTAPI GetCursorPos Z www = WindowFromPoint(Z.x, Z.y) ShowWindow www, SW_HIDE End Sub
Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal ProcessID As Long, ByVal ServiceFlags As Long) As Long '获取当前进程ID号 Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long'在任务列表中隐藏你的应用程序: Call RegisterServiceProcess(GetCurrentProcessId, 1) '显示 Call RegisterServiceProcess(GetCurrentProcessId, 0)
简单了,你启动Word后,使用FindWindow返回这个Word窗口的句柄,再使用SetWindowLong设置这个窗口为tool window即可,一个测试代码: Option Explicit Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Const GWL_EXSTYLE = (-20) Private Const WS_EX_TOOLWINDOW = &H80Private Sub Form_Load() SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOWEnd Sub如果你想设置自己的程序在状态栏中看不见,你只要在属性框中设置ShowInTaskbar为false即可
1。使用窗口的Caption找到一个窗口(Caption就是你在一个窗口左上角看到的文字) Private Sub Command1_Click() Dim iRet As Long Dim sTitle As String
sTitle = "2.doc - Microsoft Word" //改为你要找的Word窗口的Caption
iRet = FindWindow(vbNullString, sTitle)
If iRet = 0 Then MsgBox ("Could not find the word window") Exit Sub End If 'iRet即为Word窗口的句柄 End Sub2.使用Word的ClassName来查找窗口,Word的ClassName是OpusApp(你可以使用Spy++找到所有窗口的信息) Private Sub Command1_Click() Dim iRet As Long Dim sClassName As String
sClassName = "OpusApp"
iRet = FindWindow(sClassName, vbNullString)
If iRet = 0 Then MsgBox ("Could not find the word window") Exit Sub End If 'iRet即为Word窗口的句柄 End Sub找到Word窗口后,我在测试中发现使用我上面说的方法对Word窗口不起作用,我只能使用另一种变通的方法,即将我们返回Word窗口设置为我们当前运行程序的子窗口,这样Word窗口在taskbar上的图标没看不到了,应该也可以满足你的需要: Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Sub Command1_Click() Dim iRet As Long Dim sTitle As String Dim sClassName As String
sClassName = "OpusApp" sTitle = "2.doc - Microsoft Word"
再用ShowWindow使窗体隐藏。
还有用SHOWWINDOW后,好象连窗体都没有了,为什么?要怎么设设置参数?
分我可以再加的,搞定了就给分!!!!!!!!!!!!!!!!!!!!!!
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As LongPrivate Type POINTAPI
x As Long
y As Long
End TypePrivate Const SW_HIDE = 0
Private Sub Timer1_Timer()
Dim Z As POINTAPI
GetCursorPos Z
www = WindowFromPoint(Z.x, Z.y)
ShowWindow www, SW_HIDE
End Sub
试了,结果所有找开的程序和桌面上的图标都没了
http://user.7host.com/yescnet
http://perso.kilio.com/yescnet
http://home.domaindlx.com/yescnet
http://yyycnet.phidji.com
http://yescnet8.tf2hq.com
http://www.yescnet.net
http://www.websamba.com/yescnet
http://www.cnetpower.net
http://user.7host.com/cnetyes江湖
__________________ 国外空间中文解决方案,支持任何语言,支持Access2000
__________________ 动网论坛国外空间完整无错版
完全支持Access 2000http://www.yescnet.com/manage.asp?url=down/list.asp**id=90
http://user.7host.com/yescnet/manag...l=down/list.asp**id=91** 傲世江湖一鹤之国外空间版提供下载(支持非虚拟目录) **下载:http://www.yescnet.com/manage.asp?url=down/list.asp**id=91
下载:http://user.7host.com/yescnet/manag...l=down/list.asp**id=92
示例:http://user.7host.com/cnetyes** 傲世江湖一鹤之虚拟目录补丁 **http://www.yescnet.com/manage.asp?url=down/list.asp**id=92
http://user.7host.com/yescnet/manag...l=down/list.asp**id=93
不用API也能实现呀。
去看看对不对。
'获取当前进程ID号
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long'在任务列表中隐藏你的应用程序:
Call RegisterServiceProcess(GetCurrentProcessId, 1)
'显示
Call RegisterServiceProcess(GetCurrentProcessId, 0)
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TOOLWINDOW = &H80Private Sub Form_Load()
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOWEnd Sub如果你想设置自己的程序在状态栏中看不见,你只要在属性框中设置ShowInTaskbar为false即可
Private Sub Command1_Click()
Dim iRet As Long
Dim sTitle As String
sTitle = "2.doc - Microsoft Word" //改为你要找的Word窗口的Caption
iRet = FindWindow(vbNullString, sTitle)
If iRet = 0 Then
MsgBox ("Could not find the word window")
Exit Sub
End If
'iRet即为Word窗口的句柄
End Sub2.使用Word的ClassName来查找窗口,Word的ClassName是OpusApp(你可以使用Spy++找到所有窗口的信息)
Private Sub Command1_Click()
Dim iRet As Long
Dim sClassName As String
sClassName = "OpusApp"
iRet = FindWindow(sClassName, vbNullString)
If iRet = 0 Then
MsgBox ("Could not find the word window")
Exit Sub
End If
'iRet即为Word窗口的句柄
End Sub找到Word窗口后,我在测试中发现使用我上面说的方法对Word窗口不起作用,我只能使用另一种变通的方法,即将我们返回Word窗口设置为我们当前运行程序的子窗口,这样Word窗口在taskbar上的图标没看不到了,应该也可以满足你的需要:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Dim iRet As Long
Dim sTitle As String
Dim sClassName As String
sClassName = "OpusApp"
sTitle = "2.doc - Microsoft Word"
'iRet = FindWindow(vbNullString, sTitle)
iRet = FindWindow(sClassName, vbNullString)
If iRet = 0 Then
MsgBox ("Could not find the word window")
Exit Sub
End If
SetParent iRet, Me.hwnd '将Word窗口作为我们的子窗口End Sub
ShowWindow ( hWnd, SW_HIDE )