“AddressOf”出错,请大家帮我修正
提示:“AddressOf”表达式不能转换为“Long”,因为“Long”不是委托类型。(改为 Integer 亦无用处)
本人使用2005不久,请大家帮助我修改它,使其可以在VB2005中正常编译。
Public Function SetWndProc(ByVal hwnd As Long, ByVal NewWndProc As Boolean) As Long If NewWndProc Then prevWndProc = GetWindowLong(hwnd, GWL_WNDPROC) SetWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc) Else SetWndProc = SetWindowLong(hwnd, GWL_WNDPROC, prevWndProc) End If End Function Private Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = WM_HOTKEY Then Select Case wParam Case 2222 SetWindowPos(GetForegroundWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) Case 2223 SetWindowPos(GetForegroundWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) Case 2224 Form1.Close() End Select Exit Function End If WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam) End Function