|
楼主 |
发表于 2020-9-30 12:15:01
|
显示全部楼层
我现在换成WM_COPYDATA来做,可是又出现了问题,情况如下:
vb:
Private Sub Form_Load()
gHW = Me.hwnd
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub
//模块中
Public Const WM_COPYDATA = &H4A
Public Const GWL_WNDPROC = -4
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Global lpPrevWndProc As Long
Global gHW As Long
Public Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_COPYDATA
MsgBox "ok"
MsgBox lParam
WindowProc = 0
Exit Function
End Select
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function
vc:
//先获取窗口句柄
HWND hWnd = ::FindWindow(NULL, "车牌识别测试");
//在获取TextBox句柄
HWND hWndTextBox = ::FindWindowEx(hWnd, NULL, "ThunderRT6TextBox", NULL);
//::SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)m_strPlateNum);
if (::IsWindow(hWndTextBox))
{
//::SendMessage(hWndTextBox, WM_SETTEXT, 0, (LPARAM)m_strPlateNum.GetBuffer());
::SendMessage(hWnd, WM_COPYDATA, 0, (LPARAM)m_strPlateNum.GetBuffer());
}
else
{
::MessageBox(NULL, "找不到窗口", "识别", 0);
}
可是不会弹出对话框啊?
不知道问题出在哪?
|
|