让其他程序窗口隐藏的代码怎么写

南山明月 2008-11-12 11:20:01
让其他程序窗口隐藏的代码怎么写,我想让个应用程序运行着提供服务,又不想他抛头露面,怎么写个程序让他隐身,
...全文
130 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
东方之珠 2008-11-12
  • 打赏
  • 举报
回复
找到窗口句柄,然后用showwindow隐藏即可:
showwindow hWnd,SW_HIDE
SYSSZ 2008-11-12
  • 打赏
  • 举报
回复
'窗体代码
Option Explicit
Private Sub cmdToggle_Click()

If cmdToggle.Caption = "&Hide VB" Then
HideVB
cmdToggle.Caption = "&Show VB"
cmdToggle.ToolTipText = "Show the Visual Basic IDE"
Else
ShowVB
cmdToggle.Caption = "&Hide VB"
cmdToggle.ToolTipText = "Hide the Visual Basic IDE"
Show
End If

End Sub


Private Sub Form_Unload(Cancel As Integer)

ShowVB

End Sub

SYSSZ 2008-11-12
  • 打赏
  • 举报
回复
隐藏VB6.0IDE窗口的示例
'模块代码
Option Explicit

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal aint As Integer) As Integer
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Integer) As Integer
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long

Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5
Sub HideVB()

Dim CurhWnd As Long
Dim i As Integer

CurhWnd = FindWindowPartial("Microsoft Visual Basic")
i = ShowWindow(CurhWnd, SW_HIDE)

CurhWnd = FindWindowPartial("CONJURE.MAK")
i = ShowWindow(CurhWnd, SW_HIDE)

End Sub
Sub ShowVB()

Dim CurhWnd As Long
Dim i As Integer

CurhWnd = FindWindowPartial("Microsoft Visual Basic")
i = ShowWindow(CurhWnd, SW_SHOW)

CurhWnd = FindWindowPartial("CONJURE.MAK")
i = ShowWindow(CurhWnd, SW_SHOW)

End Sub
Function FindWindowPartial(ByVal TitlePart As String) As Long

Dim hWndTmp As Long
Dim nRet As Integer
Dim TitleTmp As String
Const GW_HWNDNEXT = 2

'We alter the title to compare it case-insensitively.
TitlePart = UCase$(TitlePart)

'First find all the open windows so we can
'loop through them and find the right one.
hWndTmp = FindWindow(0&, 0&)

Do Until hWndTmp = 0
TitleTmp = VBA.Space$(256)
nRet = GetWindowText(hWndTmp, TitleTmp, Len(TitleTmp))
If nRet Then
'Let's prepare to compare ;)
TitleTmp = UCase(VBA.Left$(TitleTmp, nRet))
'Now we see if the window we chased down actually
'has the caption we want.
If InStr(TitleTmp, TitlePart) Then
FindWindowPartial = hWndTmp
Exit Do
End If
End If
hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT)
Loop

End Function

1,488

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧