1
將VB6代碼升級到VB.NET時遇到了錯誤。在 AddressOf WindowProc
錯誤:'AddressOf'表達式無法轉換爲'Integer',因爲'Integer'不是委託類型
AddressOf表達發生了錯誤不能被轉換爲 '整數',因爲 '整數' 不是委託類型
我給SetWindowLong
聲明爲:
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"(
ByVal hWnd As Integer,
ByVal nIndex As Integer,
ByVal dwNewLong As Integer) As Integer
變量:
Dim GWL_WNDPROC As Short = -4
Dim hWnd As Integer
代碼WindowProc
:
Function WindowProc(ByVal hw As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim x As Integer
Dim a As String
Dim wp As Short
Dim temp As Object
Dim ReadBuffer(1000) As Byte
'Debug.Print uMsg, wParam, lParam
Select Case uMsg
Case 1025
Debug.Print(VB6.TabLayout(uMsg, wParam, lParam))
Debug.Print(uMsg & " " & wParam & " " & lParam)
e_err = WSAGetAsyncError(lParam)
e_errstr = GetWSAErrorString(e_err)
If e_err <> 0 Then
Debug.Print("Error String returned -> " & e_err & " - " & e_errstr)
Debug.Print("Terminating....")
do_cancel = True
'Exit Function
End If
Select Case lParam
Case FD_READ 'lets check for data
x = recv(mysock, ReadBuffer(0), 1000, 0) 'try to get some
If x > 0 Then 'was there any?
'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'
'default
'a = StrConv(System.Text.UnicodeEncoding.Unicode.GetString(ReadBuffer), vbUnicode) 'yep, lets change it to stuff we can understand
a = System.Text.UnicodeEncoding.Unicode.GetString(ReadBuffer) 'yep, lets change it to stuff we can understand
Debug.Print(a)
rtncode = Val(Mid(a, 1, 3))
'Debug.Print "Analysing code " & rtncode & "..."
Select Case rtncode
Case 354, 250
Progress = Progress + 1
Debug.Print(">>Progress becomes " & Progress)
Case 220
Debug.Print("Recieved Greenlight")
Green_Light = True
Case 221
Progress = Progress + 1
Debug.Print(">>Progress becomes " & Progress)
Case 550, 551, 552, 553, 554, 451, 452, 500
Debug.Print("There was some error at the server side")
Debug.Print("error code is " & rtncode)
do_cancel = True
End Select
End If
Case FD_CONNECT 'did we connect?
mysock = wParam 'yep, we did! yayay
'Debug.Print WSAGetAsyncError(lParam) & "error code"
'Debug.Print mysock & " - Mysocket Value"
Case FD_CLOSE 'uh oh. they closed the connection
Call closesocket(wp) 'so we need to close
End Select
End Select
'let the msg get through to the form
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function
是什麼錯誤我得到的原因是什麼?我該如何解決問題?
覆蓋的窗口過程在哪一行,你得到的錯誤?上面的代碼有很多錯誤。 – chrissie1
如何定義和設置lpPrevWndProc,hw,uMsg,wParam和lParam? –
@ Hand-E-Food - 'hw','uMsg','wParam'和'lParam'是'WindowProc'函數的參數。 'lpPrevWndProc'大概是存儲'SetWindowLong'的返回值的地方(但是OP當然沒有向我們顯示包含錯誤嘗試使用'SetWindowLong'來覆蓋窗口過程的實際代碼行) –