|
I changed to WM_COPYDATA to do it now, but there was a problem again, the situation is as follows:
vb:
Private Sub Form_Load()
gHW = Me.hwnd
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub
//In the module
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:
//Get the window handle first
HWND hWnd = ::FindWindow(NULL, "License Plate Recognition Test");
//Get the TextBox handle
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, "No window found", "Recognition", 0);
}
But the dialog box will not pop up?
Don't know where the problem is? |
|