[RESOLVED] Unable to StreamIN richedit. dwError = -16
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: [RESOLVED] Unable to StreamIN richedit. dwError = -16

  1. #1
    Join Date
    May 2009
    Posts
    2

    [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
    Last edited by Marc G; May 27th, 2009 at 05:38 AM. Reason: added code tags

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    827

    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

  3. #3
    Join Date
    May 2009
    Posts
    2

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center