Home > Software engineering >  The rich edit2.0 inside the text and format to the RTF file. Es. The pfnCallback=MyStreamOutCallback
The rich edit2.0 inside the text and format to the RTF file. Es. The pfnCallback=MyStreamOutCallback

Time:09-20

I use vs2010 MFC, want to have rich edit2.0 inside the text and format to the RTF file,
The static DWORD CALLBACK
MyStreamOutCallback (DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG * PCB)
{
CFile * pFile=(CFile *) dwCookie;
PFile - & gt; Write (pbBuff, cb);
* PCB=cb;
return 0;
}


CFile CFile (TEXT (" myfile. RTF), CFile: : modeCreate | CFile: : modeWrite);
EDITSTREAM es.
Es. DwCookie=(DWORD) & amp; CFile;
Es. PfnCallback=MyStreamOutCallback;
M_richedit. StreamOut (SF_RTF, es);



After intercepting the compiled appear:
The error C2440: "=" : from "DWORD (__cdecl *) (DWORD, LPBYTE, LONG, LONG *)" into "EDITSTREAMCALLBACK
"This transformation requires the reinterpret_cast, C style transformation or function type conversion
The problem was with es. PfnCallback=MyStreamOutCallback; , could you tell me where there's a problem, how to change?

CodePudding user response:

Baidu search relevant keywords,

Run into a similar problem is done with
/*... every time." */comment out different parts to recompile again, until orientation to the location of the specific grammatical errors, "
The methods to solve of,

CodePudding user response:

& MyStreamOutCallback

CodePudding user response:

To:
 static DWORD CALLBACK 
MyStreamOutCallback (DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * PCB)
{
CFile * pFile=(CFile *) dwCookie;
PFile - & gt; Write (pbBuff, cb);
* PCB=cb;
return 0;
}


CFile CFile (TEXT (" myfile. RTF), CFile: : modeCreate | CFile: : modeWrite);
EDITSTREAM es.
Es. DwCookie=(DWORD_PTR) & amp; CFile;
Es. PfnCallback=MyStreamOutCallback;
M_richedit. StreamOut (SF_RTF, es);

CodePudding user response:

In you there may not be the definition of EDITSTREAMCALLBACK
Typedef dwords (CALLBACK * EDITSTREAMCALLBACK) (DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG * PCB);
But
Typedef dwords (CALLBACK * EDITSTREAMCALLBACK) (DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * PCB);

CodePudding user response:

Is defined as an early version of it with a DWORD_PTR
EDITSTREAMCALLBACK callback function
  • Related