C ++ WIN32 RichEdit控件不要放置流

时间:2018-08-01 11:32:58

标签: c++ win32gui richedit-control

我尝试将数据放入RichEdit50W,但是它不起作用。我真的需要帮助。

我的函数CreateRichEdit:

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);

    char * bidule = "coucou c'est moi";
    EDITSTREAM es = { 0 };
    es.dwCookie = (DWORD_PTR)bidule;
    es.dwError = 0;
    es.pfnCallback = EditStreamInCallback;

    bool ok = false;
    if (SendMessage(edittext, EM_STREAMIN, SF_RTF, (LPARAM)&es) == 0) {
       ok = true;
    }
}

在函数EditStreamInCallback中,在变量“ txt”中,我很好地得到了文本“ coucou c'est moi”。但是之后,当我尝试用pbBuff编写时,在富文本框中看不到结果:

DWORD CALLBACK EditStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
   if (!cb)
      return (1);

   char * txt = (char *) dwCookie;

   int i;

   for (i = 0; i < 3; i++)
   {
       *(pbBuff + i) = 'a';
   }
   *(pbBuff + i) = '\0';
   *pcb = 3;

   return (0);
}

我绝对需要帮助!请问您有什么解决办法吗?

提前谢谢

0 个答案:

没有答案