【开源项目】花密(Flower Password)VB版之窗体控件枚举模块

来源:互联网 发布:java的脚本语言 编辑:程序博客网 时间:2024/06/05 04:09
'*****************************************************************' Copyright (c) 2011-2012 FlowerPassword.com All rights reserved.'      Author : xLsDg @ Xiao Lu Software Development Group'        Blog : http://hi.baidu.com/xlsdg'          QQ : 4 4 7 4 0 5 7 4 0'     Version : 1 . 0 . 0 . 0'        Date : 2 0 1 2 / 0 4 / 0 7' Description :'     History :'*****************************************************************Option ExplicitPrivate Declare Function SendMessage _                Lib "user32" _                Alias "SendMessageA" (ByVal hwnd As Long, _                                      ByVal wMsg As Long, _                                      ByVal wParam As Long, _                                      lParam As Any) As LongPrivate Declare Function GetWindow _                Lib "user32" (ByVal hwnd As Long, _                              ByVal wCmd As Long) As LongPrivate Declare Function GetClassName _                Lib "user32" _                Alias "GetClassNameA" (ByVal hwnd As Long, _                                       ByVal lpClassName As String, _                                       ByVal nMaxCount As Long) As LongPrivate Const GW_CHILD = 5Private Const GW_HWNDNEXT = 2Private Const WM_GETTEXT = &HDPrivate Const WM_GETTEXTLENGTH = &HE' Return information about this window.Public Function WindowInfo(ByVal window_hwnd As Long, _                           ByVal class_name As String) As String    Static txt As String    Dim buf    As String    Dim buflen As Long    ' Get the class name.    buflen = 256    buf = Space$(buflen - 1)    buflen = GetClassName(window_hwnd, buf, buflen)    buf = Left$(buf, buflen)    If LCase$(buf) = class_name Then        ' Associated text.        txt = WindowText(window_hwnd)        Exit Function    End If    Dim child_hwnd As Long    Dim children   As Collection    ' Make a list of the child windows.    Set children = New Collection    child_hwnd = GetWindow(window_hwnd, GW_CHILD)    Do While child_hwnd <> 0        children.Add child_hwnd        child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT)    Loop    Dim i As Integer    ' Get information on the child windows.    For i = 1 To children.count        WindowInfo children(i), class_name    Next i    WindowInfo = txtEnd Function' Return the text associated with the window.Public Function WindowText(ByVal window_hwnd As Long) As String    Dim txtlen As Long    Dim txt    As String    WindowText = vbNullString    If window_hwnd = 0 Then Exit Function    txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)    If txtlen = 0 Then Exit Function    txtlen = txtlen + 1    txt = Space$(txtlen)    txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)    WindowText = Left$(txt, txtlen)End Function


原创粉丝点击