【求助】回调函数问题
vb.net吧
全部回复
仅看楼主
level 1
TuskAi 楼主
本人新手,在网上找了一段VB的代码,想改成VB.NET
涉及到回调,一直改不正确
原语句
EnumChildWindows twnd, AddressOf EnumChildProc, ByVal 0&
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
我改成了
EnumChildWindows(twnd, AddressOf EnumChildWindowsCallBack, 0&)
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Integer, lpEnumFunc As EnumChildWindowsCallBack, ByVal lParam As Integer) As Integer
Public Function EnumChildWindowsCallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Integer
系统提示
错误1未定义类型“EnumChildWindowsCallBack”。
2016年02月27日 12点02分 1
level 1
TuskAi 楼主
2016年02月27日 12点02分 2
level 9
先声明一个委托: Public Delegate Function EnumChildProc(hwnd As Integer, iParam As Integer) As Integer,然后才能使用回掉函数,你回掉函数的参数要和委托完全一致。然后你那个 API 函数需要这样声明: Declare Function EnumChildWindows Lib "user32" (hWndParent As Integer, lpEnumFunc As EnumChildProc, lParam As Integer) As Integer
2016年02月27日 14点02分 3
谢谢,确实不报错了,我再消化一下
2016年02月27日 14点02分
我在百度知道提问了这个问题,你把这个答案粘贴过去,我把积分给你吧 http://zhidao.baidu.com/question/1833065254076896900.html
2016年02月27日 14点02分
回复
复仇之牙
:已粘贴。
2016年02月27日 14点02分
1