隐藏其它程序上的控件

11111111adsfafdas 2009-04-09 06:44:20
代码目的是针对其它程序,隐藏其它程序上的控件,要隐藏的控件位于 tab 容器内,然后在TAB容器内有放了一个Frame2,然后文本控件在frame2内,下面是我的代码,不知道哪里错了,请各位大大帮忙看看,谢谢了。
'以下是代码:
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
Const WM_SETTEXT = &HC

Private Sub Command1_Click()
Dim h1 As Long
Dim h2 As Long
Dim h3 As Long
Dim h4 As Long

h1 = FindWindow("ThunderFormDC", vbNullString)
h2 = FindWindowEx(h1, 0&, "SSTabCtlWndClass", vbNullString)
h3 = FindWindowEx(h2, 1&, "ThunderFrame", vbNullString)
h4 = FindWindowEx(h3, 2&, "ThunderRT6TextBox", vbNullString)

Text1 = h4
ShowWindow y, SW_HIDE
End Sub
...全文
98 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
东方之珠 2009-04-10
  • 打赏
  • 举报
回复
ShowWindow 只用于窗体
btxdlibin 2009-04-10
  • 打赏
  • 举报
回复
const SW_HIDE =&H0 '虽然可以不写,但要养成好习惯
ShowWindow h4, SW_HIDE '参数:hwnd是目标句柄 (你就算抄也要变化下啊).

'如果,h1,h2,h3,h4任何一个=0,说明是那里的句柄取错了.
'FindWindowEx 的参数:hWnd2,不知道你有没有看懂,没Spy分析过的话.很难看出这样的参数.

'总结下:多看看句柄这方面的知识.不要拿来主义.

BTW:再更正下1L的看法.ShowWindow用于有句柄的设备(控件、窗体..)

1,488

社区成员

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

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