作者eddiesu (EddieSu)
看板Programming
标题[问题] VB.NET EnumChildWindows列举物件
时间Fri Sep 21 00:23:51 2012
各位先进,
小弟东拼西凑,做中学,现在实在来不及了,所以斗胆上来请益 ^^b
现在手上有这二个function,能请高手帮写一个function,传入hwnd,传回该视窗所有物件的arraylist
============================================================================
Private Function GetWindowIdentification(ByVal hwnd As Long, ByRef sIDType As String, ByRef sClass As StringBuilder) As String
Dim nSize As Long
Dim sTitle As New StringBuilder("", 256)
'get the size of the string required
'to hold the window title
Dim sClassName As New StringBuilder("", 256)
'pass in the handle of the object for which to get
'the class name; for example, the form's handle
nSize = GetWindowTextLength(hwnd)
'if the return is 0, there is no title
If nSize > 0 Then
Dim ay As New Rectangle
GetWindowRect(hwnd, ay)
'MsgBox(Me.PointToClient(ay.Location).ToString)
GetWindowText(hwnd, sTitle, 256)
'Call GetClassName(hwnd, sTitle, 256)
'no title, so get the class name instead
Call GetClassName(hwnd, sClass, 256)
sIDType = "class & name"
End If
Return Trim(sTitle.ToString)
End Function
Public Function EnumChildProc(ByVal hwnd As IntPtr, ByRef lParam As IntPtr) As Integer
'working vars
Dim sTitle As String
Dim sClass As New StringBuilder(100000)
Dim sIDType As String = ""
'get the window title / class name
sTitle = GetWindowIdentification(hwnd, sIDType, sClass)
'add to the listview
MsgBox(sTitle & sClass.ToString)
' Listview_IndentItem(.hwnd, CLng(itmX.Index), 1)
EnumChildProc = 1
End Function
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 42.73.24.154