以下使用sendmessage的vb代码如何修改成vb.net的代码?请指教,谢谢。
我刚从vb环境转到vb.net,很不适应。OptionExplicitPrivateDeclareFunctionSendMessageLib"user32"Alias"...
我刚从vb环境转到vb.net,很不适应。
Option Explicit
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 GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const WM_GETTEXT = &HD&
Private Const WM_GETTEXTLENGTH = &HE&
'Dim a As Long
Dim GetIParam As Long
Dim GetString As String * 255
Private Sub Command1_Click()
Text1.Text = Command1.hwnd
'a = SendMessage(CLng(Text1.Text), WM_GETTEXTLENGTH, 0, 0)
SendMessage CLng(Text1.Text), WM_GETTEXT, 255, ByVal GetString '255是缓冲区的长度
'GetKeyNameText GetIParam, GetString, Len(GetString)
MsgBox GetString
End Sub 展开
Option Explicit
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 GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const WM_GETTEXT = &HD&
Private Const WM_GETTEXTLENGTH = &HE&
'Dim a As Long
Dim GetIParam As Long
Dim GetString As String * 255
Private Sub Command1_Click()
Text1.Text = Command1.hwnd
'a = SendMessage(CLng(Text1.Text), WM_GETTEXTLENGTH, 0, 0)
SendMessage CLng(Text1.Text), WM_GETTEXT, 255, ByVal GetString '255是缓冲区的长度
'GetKeyNameText GetIParam, GetString, Len(GetString)
MsgBox GetString
End Sub 展开
展开全部
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
'Private Declare Function GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const WM_GETTEXT As Integer = &HD
Private Const WM_GETTEXTLENGTH As Integer = &HE
'Dim a As Long
Dim GetIParam As Integer
Dim GetString As String
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
GetString = Space(255)
'a = SendMessage(CLng(Text1.Text), WM_GETTEXTLENGTH, 0, 0)
Text1.Text = Command1.Handle.ToInt32
SendMessage(CInt(Text1.Text), WM_GETTEXT, 255, GetString) '255是缓冲区的长度
'GetKeyNameText GetIParam, GetString, Len(GetString)
MsgBox(GetString)
End Sub
'Private Declare Function GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const WM_GETTEXT As Integer = &HD
Private Const WM_GETTEXTLENGTH As Integer = &HE
'Dim a As Long
Dim GetIParam As Integer
Dim GetString As String
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
GetString = Space(255)
'a = SendMessage(CLng(Text1.Text), WM_GETTEXTLENGTH, 0, 0)
Text1.Text = Command1.Handle.ToInt32
SendMessage(CInt(Text1.Text), WM_GETTEXT, 255, GetString) '255是缓冲区的长度
'GetKeyNameText GetIParam, GetString, Len(GetString)
MsgBox(GetString)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询