AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.
Код формы
- Код: Выделить всё
Imports WastesRegister.clWinApi
Public Class frmMain
Dim hwndDXF As Long
Dim nTop As Single
Dim nLeft As Single
Private Sub btnFindChildWindows_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFindChildWindows.Click
EnumChildWindows(hwndDXF, AddressOf EnumChildWindowsProc, &H0)
End Sub
Private Function EnumChildWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim oNewLbl As New Label
Static i As Long
With oNewLbl
.Text = i.ToString & " hwnd = &H" & Hex(hwnd).ToString
.Top = nTop + 6
nTop = .Top
nTop = .Top + .Height
.Left = nLeft
.Visible = True
End With
Me.Controls.Add(oNewLbl) : i += 1
EnumChildWindowsProc = True
End Function
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
nTop = Label1.Top + Label1.Height
nLeft = Label1.Left
End Sub
End Class
Объявления функций API
- Код: Выделить всё
Public Class clWinApi
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Public Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Int32
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Int32
End Class