VB 已知窗体句柄,如何取各控件的句柄,各控件没有标题,类名均为WindowsForms10.EDIT.app.0.378734a,

 我来答
KL1112
2012-02-27 · TA获得超过532个赞
知道小有建树答主
回答量:454
采纳率:0%
帮助的人:625万
展开全部
参考如下代码:

Option Explicit

Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hWnd As Long, ByVal wFlag As Long) As Long
Private Const GW_CHILD = 5
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDLAST = 1
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDPREV = 3
Private Const GW_OWNER = 4

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Public Function GetChild(ByVal hWnd As Long) As Long
Dim L1 As Long, L2 As Long, s As String

L2 = GetNextWindow(hWnd, GW_CHILD)
If L2 = 0 Then Exit Function
With Form1.List1
Do
L1 = 255: s = String(L1, Chr(0))
L1 = GetClassName(L2, s, L1): s = Left(s, L1)
.AddItem CStr(L2) & ":" & s

L1 = L2: L2 = GetChild(L2)

L2 = GetNextWindow(L1, GW_HWNDNEXT)
If L2 = 0 Then Exit Do
Loop
End With
End Function
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式