Evo ovako:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Const SW_SHOWNORMAL = 1
Const GW_CHILD = 5
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDNEXT = 2
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_SETTEXT = &HC
Dim tWnd As Long, bWnd As Long, sSave As String * 250, a As String, str As String
Private Sub Form_Load()
Procitaj
End Sub
Private Sub Procitaj()
Dim tmp As String
' Uzimamo hWnd objekta/prozora koji ima oznaku Forma
tWnd = FindWindow(vbNullString, "Forma")
' Ovako dolazimo do njegovog prvog child objekta
bWnd = GetWindow(tWnd, GW_CHILD)
Do While Not bWnd = 0
' Provjeravamo o kojoj se kalsi radi...
GetClassName bWnd, sSave, 250
' i ako je u pitanju ListBox
If InStr(1, sSave, "ListBox") > 0 Then
' Prosledjujemo njegovu adresu funkciji WindowTextGet koja ce očitati upisani tekst.
tmp = WindowTextGet(bWnd)
If InStr(1, tmp, "http:") = 0 Then
str = str & vbCrLf & tmp
End If
End If
' Ovako uzimamo adresu sledećeg objekta
bWnd = GetWindow(bWnd, GW_HWNDNEXT)
Loop
End Sub
Private Function WindowTextGet(ByVal hwnd As Long) As String
Dim strBuff As String, lngLen As Long
lngLen = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0)
If lngLen > 0 Then
lngLen = lngLen + 1
strBuff = String(lngLen, vbNullChar)
lngLen = SendMessage(hwnd, WM_GETTEXT, lngLen, ByVal strBuff)
WindowTextGet = Left(strBuff, lngLen)
End If
End Function
SELECT * FROM หน่วยงานหลัก WHERE ยสันติ LIKE 'โดย%'