假如我在form1里有个command的控件我如何得到他的窗口句柄?不要command.hwnd
也不要返回鼠标位置的窗口句柄那个api.我的意思是通过form1的句柄得到command的句柄.或其他的方法
也不要返回鼠标位置的窗口句柄那个api.我的意思是通过form1的句柄得到command的句柄.或其他的方法
解决方案 »
- vb 下面的代码怎么编程
- Excel中使用VBA删除一行单元,不是一行数据?
- MDI子窗体Toolbar到主窗体
- 如何用从INI读出来的参数 来动态加 控件(SSTAB.LABEL.TXTBOX) 急 求救高手 在线等~
- 我是没有办法了!一个问题搞了两天了!现在只有求救了!!
- VB写的软件在 XP 和 2003 可以运行 可到了 WINDOWS2003 SP4 运行提示 AX错误
- 招聘VB程序员1名、销售2名---工作地:无锡
- 我想问一下什么是程序的“鲁棒性”,见笑了!!
- 基于EXCEL+ACCESS+BI(数据挖掘与数据钻取、多维查询、全文检索)理念设计的个人工作管理簿
- 请问如何在VB里使用很旧版本扩展名为.DBF的表?
- 一个sql语句的编写
- 那里出错了?
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Sub Form_Load()
Dim hCommand1 As Long
hCommand1 = FindWindowEx(Me.hWnd, 0&, "ThunderCommandButton", "Command1")
MsgBox CStr(hCommand1) & vbCrLf & CStr(Command1.hWnd)
End Sub
放上一个Command1
GetChild(hWnd, HWND_NEXT)
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Const GW_CHILD = 5
Const GW_HWNDNEXT = 2
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Sub Command2_Click()
Dim frmHwnd As Long
Dim bWnd As Long
Dim strClassName As String * 250
Dim MyStr As String
Dim intLen As Integer
frmHwnd = Me.hwnd '已知的窗口句柄
bWnd = GetWindow(frmHwnd, GW_CHILD)
Do While bWnd <> 0
GetClassName bWnd, strClassName, 250
'如果是VB的按钮,则下面的是thundercommandbutton,如里不是,那么则可能是button
If InStr(1, strClassName, "ThunderCommandButton") <> -1 Then
'判断按按钮的标签
intLen = GetWindowTextLength(bWnd)
MyStr = String(intLen + 1, Chr$(0))
Call GetWindowText(bWnd, MyStr, Len(MyStr))
If InStr(1, MyStr, "按钮名") <> -1 Then MsgBox "已搜索出句柄:" & bWnd
End If
bWnd = GetWindow(bWnd, GW_HWNDNEXT)
Loop
End Sub