如何从richedit读取一些数据到缓冲区? [英] how read some data to a buffer from richedit?

查看:97
本文介绍了如何从richedit读取一些数据到缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读取读取richedit数据的方法:

i'm doing a reading method for read some data from richedit:

void APIDoEvents()
    {
        MSG msg;
        BOOL result;

        while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE ))
        {
            if(blnread==false)
                break;
            result = ::GetMessage(&msg, NULL, 0, 0);
            if (result == 0) // WM_QUIT
            {
                ::PostQuitMessage(msg.wParam);
                break;
            }
            else if (result == -1)
            {
                 // Handle errors/exit application, etc.
            }
            else
            {
                ::TranslateMessage(&msg);
                ::DispatchMessage(&msg);
            }
        }
    }

    string read()
    {
        blnread=true;
        APIDoEvents();//until the blnread igual a false
        DebugText("hi");
        return strreaded;
    }
//rich edit procedure(subclassed):
switch(uMsg)
        {
            case WM_KEYDOWN:
            {
                if((wParam==VK_RETURN) && (richedit->blnread==true))
                {
                    richedit->blnread=false;
                }
                return 0;
            }
            break;
            case WM_KEYUP:
            {
                if(richedit->blnread==true)
                    richedit->strreaded=richedit->strreaded + to_string(wParam);

                return 0;
            }
            break;
        }
        return CallWindowProc(richedit->wpOrigRichEditProc,hwndDlg,uMsg,wParam,lParam);

我看到这些代码有2个问题:

i see 2 problems on these code:

1 - APIDoEvents()支持来自同一个treath的另一个窗口:(

1 - the APIDoEvents() affets another window from same treath :(

2 - 输入键似乎未经过测试。 't :(

2 - the enter key seems not tested. acts like been pressed when wasn't :(

我做错了什么?

推荐答案

@Cambalinho,

@Cambalinho,

看起来像win32项目,但我不太确定。你介意分享你的样本供别人测试吗?

Looks like a win32 project, but I'm not so sure. Would you mind to share your sample for others to test?

你是什么?通过说"影响另一个窗口"来表示。你想如何输入密钥才能在这里工作?你的代码似乎没有写关于输入密钥的信息。

What do you mean by saying "affect another window". And how do you want to enter key to work here? You code seems wrote nothing about enter key here.

祝你好运,

Barry


这篇关于如何从richedit读取一些数据到缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆