VB.NET and EM_STREAMOUT

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
 
G

Guest

Hi

I know its not exactly what you are looking for, but its sort of there.
Navigate to:

http://www.msde.biz/vbnetfaq.htm

Scroll down the page & look for the example called 'Using the Char2Format
Structure in VB .NET for Highlighting Text'

It just highlights the text & chages it to red, but shouldn't be too much
trouble to convert it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top