回覆列表
  • 1 # 狼族部落搞笑影視推薦

    這個可能是你想要的東東吧!=========================VB 遍歷視窗所有子窗體控制代碼Private Const GW_CHILD = 5Private Const GW_HWNDFIRST = 0Private Const GW_HWNDNEXT = 2Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As LongPrivate Declare Function IsWindow Lib "user32" (ByVal hwnd 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 Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As LongPrivate Sub FillChild(hWndParent As Long)Dim hWndChild As LongDim szCaption As StringDim buffer As StringDim i As LonghWndChild = GetWindow(hWndParent, GW_CHILD)If (hWndChild = 0) Then Exit SubhWndChild = GetWindow(hWndChild, GW_HWNDFIRST)If hWndChild = 0 Then Exit SubWhile (hWndChild <> 0)szCaption = String$(255, 0)GetClassName hWndChild, szCaption, 250szCaption = Left$(szCaption, InStr(szCaption, String$(1, 0)) - 1)buffer = CStr(hWndChild) & "--" & szCaptioni = GetWindowTextLength(hWndChild)szCaption = String$(255, 0)GetWindowText hWndChild, szCaption, 250szCaption = Left$(szCaption, i)buffer = buffer & "--" & szCaptionList1.AddItem bufferFillChild hWndChildhWndChild = GetWindow(hWndChild, GW_HWNDNEXT)WendEnd SubPrivate Sub GetChildWindow(hwnd As Long)Dim szCaption As StringDim buffer As StringDim i As LongList1.ClearszCaption = String$(255, 0)GetClassName hwnd, szCaption, 250szCaption = Left$(szCaption, InStr(szCaption, String$(1, 0)) - 1)buffer = CStr(hwnd)buffer = buffer & "--" & szCaptioni = GetWindowTextLength(hwnd)szCaption = String$(255, 0)GetWindowText hwnd, szCaption, 250szCaption = Left$(szCaption, i)buffer = buffer & "--" & szCaptionList1.AddItem bufferFillChild hwndEnd Sub呼叫方法GetChildWindow hwnd"hwnd是指定的視窗控制代碼結果以窗體控制代碼--窗體類名稱--窗體Text形式列在列表框List1中

  • 中秋節和大豐收的關聯?
  • 集顯核顯獨顯區別?