C++ WIN32 - Load RTF Data to Rich Edit Control

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


C++ WIN32 - Load RTF Data to Rich Edit Control



I try to load text (formatting in 'RTF') to my rich text control but it doesn't work. I've even tried to use 'WriteFile((HANDLE)dwCookie, myBuff, cb, (DWORD*)pcb, NULL)' instead of 'pcb = rtf->readsome((char)pbBuff, cb);'


void CreateRichEdit(HWND hwndOwner, int x, int y, int width, int height, HINSTANCE hinst)
{
LoadLibrary(TEXT("Msftedit.dll"));

edittext = CreateWindowEx(0, TEXT("RICHEDIT50W"), TEXT("Type here"), ES_MULTILINE | WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP | ES_AUTOVSCROLL | WS_VSCROLL,
x, y, width, height,
hwndOwner, NULL, hinst, 0);
std::string teext = "{rtf1ansi{fonttbl{ f0fnilfcharset0fprq0fttruetype Helvetica; }{f1fnilfcharset0fprq0fttruetype Bitstream Charter; }}{f1fs24 Ceci est un texte accentu'e9}par{ f0fs24 avec des caract'e8res {b gras},}par{ f1 des{ fs18 petits } et des{ fs32 gros }. }}";

std::stringstream rtf("{rtf1ansi{fonttbl{ f0fnilfcharset0fprq0fttruetype Helvetica; }{f1fnilfcharset0fprq0fttruetype Bitstream Charter; }}{f1fs24 Ceci est un texte accentu'e9}par{ f0fs24 avec des caract'e8res {b gras},}par{ f1 des{ fs18 petits } et des{ fs32 gros }. }}");
//std::stringstream rtf("...");

EDITSTREAM es = { 0 };
es.dwError = 0;
es.dwCookie = (DWORD_PTR)&rtf;
es.pfnCallback = EditStreamInCallback;

SendMessage(edittext, EM_STREAMIN, SF_RTF, (LPARAM)&es);
}


DWORD CALLBACK EditStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{

std::stringstream * rtf = (std::stringstream*) dwCookie;
std::string text = (*rtf).str();
char myBuff[500];
*pcb = rtf->readsome((char*)pbBuff, cb);

return *pcb;
}



I've also tried to uncomment 'std::stringstream rtf("...");' just for writing '...' in my edit control but it doesn't work.



Can you help me ?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Future solutions