G
Guest
I am trying to use the EM_STREAMOUT message to get RichEdit Control data from
another application. I have found several examples on the web for C++ and
C#. I have tried to convert them, but the call always crashes the window I
am trying to get the data from. Does anybody know where I can find a clear
cut example for VB.NET?
I've tried a several scenarios for the data types and ByRef for the pcb
parameter. Here's what I have right now.
Public Declare Auto Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef
lParam As EDITSTREAM) As IntPtr
Delegate Function EditStreamCallback(ByVal dwCookie As Int32, ByVal pbBuff
As Int32, ByVal cb As Int32, ByVal pcb As Int32) As Int32
Structure EDITSTREAM
Public dwCookie As Int32
Public dwError As Int32
Public pfnCallback As EditStreamCallback
End Structure
Dim eData As EDITSTREAM
'eData.dwCookie = IntPtr.Zero
eData.dwCookie = frmMainUI.txtReturnBox.Handle.ToInt32
eData.dwError = 0
eData.pfnCallback = AddressOf handleRichEditCallback
SendMessage(hReturn, EM_STREAMOUT, 1, eData) ' this call crashes
window with handle hReturn
SendMessage(hReturn, EM_SETMODIFY, 1, 0)
' This callback function never gets triggered
Public Function handleRichEditCallback(ByVal dwCookie As Int32, ByVal pbBuff
As Int32, ByVal cb As Int32, ByVal pcb As Int32) As Int32
MsgBox("Cool")
End Function
another application. I have found several examples on the web for C++ and
C#. I have tried to convert them, but the call always crashes the window I
am trying to get the data from. Does anybody know where I can find a clear
cut example for VB.NET?
I've tried a several scenarios for the data types and ByRef for the pcb
parameter. Here's what I have right now.
Public Declare Auto Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef
lParam As EDITSTREAM) As IntPtr
Delegate Function EditStreamCallback(ByVal dwCookie As Int32, ByVal pbBuff
As Int32, ByVal cb As Int32, ByVal pcb As Int32) As Int32
Structure EDITSTREAM
Public dwCookie As Int32
Public dwError As Int32
Public pfnCallback As EditStreamCallback
End Structure
Dim eData As EDITSTREAM
'eData.dwCookie = IntPtr.Zero
eData.dwCookie = frmMainUI.txtReturnBox.Handle.ToInt32
eData.dwError = 0
eData.pfnCallback = AddressOf handleRichEditCallback
SendMessage(hReturn, EM_STREAMOUT, 1, eData) ' this call crashes
window with handle hReturn
SendMessage(hReturn, EM_SETMODIFY, 1, 0)
' This callback function never gets triggered
Public Function handleRichEditCallback(ByVal dwCookie As Int32, ByVal pbBuff
As Int32, ByVal cb As Int32, ByVal pcb As Int32) As Int32
MsgBox("Cool")
End Function