包含vb.net实例大全的词条( 三 )


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1_Click(sender, e)
End Sub
' EnumChildWindows 回调函数,该函数名作为API函数EnumChildWindows 的一个参数
' 该函数实现了枚举各个子窗口,找出编辑框属性的功能
Public Function EnumChildProcC(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean
Dim dwWindowClass As StringBuilder = New StringBuilder(100)
' 获得某一个句柄的类名
GetClassName(hwnd, dwWindowClass, 100)
If dwWindowClass.ToString.Contains("EDIT") Or dwWindowClass.ToString.Contains("Edit") Then' 类名包含EDIT的为编辑框
EditHandle.Add(hwnd)' 存储该句柄
End If
' 返回 True 一直枚举完
Return True
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WindowHandle = FindWindow(vbNullString, "登陆")
If WindowHandle.ToInt32 = 0 Then
MsgBox("未捕获到窗口" + "登陆")
Return
End If
' 枚举所有主窗口的子窗口(控件),枚举时自动调用回调函数,完成编辑框句柄的获取
EnumChildWindows(WindowHandle, AddressOf EnumChildProcC, 0)
' 寻找复选框
CheckHandle = FindWindowEx(WindowHandle, IntPtr.Zero, vbNullString, "记住密码")
Dim str As New StringBuilder
Dim j As Integer = 0
' 对编辑框文本赋值
For j = 0 To EditHandle.Count - 1
SendMessage(EditHandle(j), WM_SETTEXT, 0, "Text")
'GetWindowText(EditHandle(j), str, 20)
'EditWindowsText.Add(Str.ToString)
'Str.Clear()
Next
If EditHandle.Count = 0 Then
MsgBox("未找到输入框!")
End If
If CheckHandle.ToInt320 Then
'CheckDlgButton(WindowHandle, id, 1)
' 对复选框进行鼠标单击操作
SendMessage(CheckHandle, BM_CLICK, 0, 0)
'SendMessage(CheckHandle, BM_SETCHECK, True, 0)
End If
End Sub
End Class
关于vb.net实例大全和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读