'创建一个列表框和一个按钮'API函数定义Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) 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 LongConst GW_HWNDFIRST = 0Const GW_HWNDNEXT = 2Private Sub Command1_Click()Dim s As LongDim a As Stringa = Space(255)s = GetWindow(Me.hwnd, GW_HWNDFIRST) '获得句柄GetWindowText s, a, 255 '获得标题Dim ab As String * 255GetClassName s, ab, 255 '获得类名Dim ClassName As StringClassName = StripTerFlag(ab) 'StripTerFlag是一个自定义函数,后面有代码,用于去处结束符If UCase(ClassName) = "NOTEPAD" ThenList1.AddItem aList1.ItemData(List1.ListCount - 1) = sEnd IfDo While sDoEventss = GetWindow(s, GW_HWNDNEXT) '获得句柄GetWindowText s, a, 255 '获得标题GetClassName s, ab, 255 '获得类名ClassName = StripTerFlag(ab)If UCase(ClassName) = "NOTEPAD" ThenList1.AddItem aList1.ItemData(List1.ListCount - 1) = sEnd IfLoopEnd SubPrivate Sub List1_Click()MsgBox List1.ItemData(List1.ListIndex) '单击列表框获得句柄End Sub
1 回答
阿波罗的战车
TA贡献1862条经验 获得超6个赞
ClassName = StripTerFlag(ab) 'StripTerFlag是一个自定义函数,后面有代码,用于去处结束符
你是不是把这个StripTerFlag过程代码放到模块中 而这个过程是Private私有过程 修改成public公用即可
- 1 回答
- 0 关注
- 332 浏览
添加回答
举报
0/150
提交
取消