[RESOLVED] Unable to StreamIN richedit. dwError = -16
I am trying to copy RTF Text from one rich edit control to another (Rich Edit 4.1).
The Code Works fine on x64.
When the same code is compiled for x86, the rtf text is streamed out from one control successfully but the nothing is stream (SendMessage() returns Zero) when streaming in the RTF Text to another control.
Following is the code:
Code:
DWORD EditStreamCallback(DWORD_PTR dwCookie,LPBYTE pbBuff,LONG cb,LONG* pcb)
{
RTFDATA* prtfData = (RTFDATA *)dwCookie;
if(prtfData->Direction==__OUT)
{
*pcb = cb;
prtfData->pDataBytes=(LPBYTE)malloc(cb);
CopyMemory(prtfData->pDataBytes,pbBuff,cb);
prtfData->nDataBytes=cb;
}
if(prtfData->Direction==__IN)
{
if(prtfData->nDataBytes<cb)
{
*pcb = prtfData->nDataBytes;
memcpy(pbBuff,(void *)prtfData->pDataBytes,*pcb);
}
else
{
*pcb = cb;
memcpy(pbBuff,(void *)prtfData->pDataBytes,*pcb);
prtfData->pDataBytes+=cb;
}
}
return 0;
}
typedef struct structRTFData2{
LPBYTE pDataBytes;
size_t nDataBytes;
WORD Direction;
}RTFDATA,*LPRTFDATA;
RTFDATA rtfData;
Is there any documentation about dwerror of EDITSTREAM.
(In My Case, dwError = -16)
Please help me to figure out the problem.
JAI SAYAN
Re: Unable to StreamIN richedit. dwError = -16
That's funny that moderators have to add code tags for you :)
Check samples on this page:
http://cboard.cprogramming.com/windo...rich-edit.html
Re: Unable to StreamIN richedit. dwError = -16
Problem Resolved.
While Debugging I found in the disassembled code that the SendMessage() wasn't returning and throwing 'illegal memory access' Exception too.
Then I Looked upon the callback function code and found that the "CALLBACK" was missing in callback function's definition.
Now it is working on x86 Platform too. May be x64 compiler is smart enough in branching and linking the subroutines of assembly. Or what else could be the reason that the code was not only compiling successfully but also working perfectly on XP/Vista x64???
Anyways Thanks 'dc 2000'.
JAI SAYAN