Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading from a RichEdit in seperate Process

Status
Not open for further replies.

jpeto

Programmer
Oct 11, 2005
2
US
I'm new to C#, so forgive me if this is basic stuff. I'm trying to use the SendMessage API call using the EM_STREAMOUT message to read data from a RichEdit Text box running in a seperate process. The call takes a pointer to a structure. One of the memebers of the structure is a function pointer to a callback function. Below is what my code currently looks like. At this point all I've attempted to do is test to see if the callback function is ever called, which it is not (that's why there's no code there yet). I'm just trying to determine what I may be doing wrong to prevent the API from calling the callback function. Many thanks to anyone who bothers to invest some time taking a look at this. My apologies if the formatting is bad- I tried to get it as readable as possible.

//Delegate declaration
public unsafe delegate bool CallBackEdit(long dwCookie, StringBuilder pbBuff, long cb, long *pcb);

//Structure declaration
public unsafe struct EditStream
{
public string dwCookie;
public string dwError;
public CallBackEdit pfnCallback;

public void SetCallBack()
{
CallBackEdit myCallBack = new CallBackEdit(Form1.Report);
pfnCallback = myCallBack;
dwCookie = "Test";
dwError = "Test";

}
}

//SendMessage Call
private unsafe void button1_Click(object sender, System.EventArgs e)

{

int handle;
long WM_USER = 0x0400;
long EM_STREAMOUT = WM_USER + 74;
long SF_RTF = 0x0002;
handle = int.Parse(textBox1.Text);

EditStream Edit = new EditStream();

Edit.SetCallBack();

SendMessage(handle, EM_STREAMOUT, SF_RTF, Edit);

}

//Callback Function
public unsafe static bool Report(long dwCookie, StringBuilder pbBuff, long cb, long *pcb)

{

return true;

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top