如何在RichEdit2可视化c中显示所有ASCII字符++

发布于 2025-01-01 05:51:02 字数 1171 浏览 1 评论 0原文

我想显示所有 ascii 字符(http://msdn.microsoft.com/en-us /library/Aa245273) 在 Visual C++ 的 richEdit2 控件中包括 NULL 但我不知道如何?

所以请帮帮我,我该怎么做?

实际上我可以显示所有字符,但是当从 richedit 框中找到 ASCII NUL 时,不会显示任何其他字符,并且我想显示所有字符,下面给出了我的代码,请帮助我,

下面给出了我的代码

void CclientCheckDlg::ReadFileData()
{

    char *readfilename= configfilepath ;
    //FILE *fp=fopen(readfilename ,"r");
    std::ifstream openFile(readfilename,std::ios::out | std::ios::binary);
    //string s;
    unsigned char c;
    //std::string s;

    int i=0;
    do
    {
        c=openFile.get();
        if(c==EOF||i==999)
            break;

        unsignedCharPointer[i]=c;
        i++;
        printf("%c",c);
    }while(!openFile.eof());
    //fclose(fp);
    CString cs(unsignedCharPointer);
    OutputDebugString(cs);
//  configArrStr=s.c_str();
    int begin=m_rich_edit.GetTextLength();
    m_rich_edit.SetSel(begin,begin);
//  CA2CT ct(unsignedCharPointer);
    lpctstr=(LPCTSTR)unsignedCharPointer;
    OutputDebugString(lpctstr);
    m_rich_edit.ReplaceSel(cs);
}

,所以请任何人都可以帮助我,如何显示空字符?

I want to display all ascii characters(http://msdn.microsoft.com/en-us/library/Aa245273) including NULL in richEdit2 control of visual c++ but i don't know how?

so please help help me how can i do this?

Actually i can show all character but when ASCII NUL is found from that richedit box doesn't show any further character and i want to display all character my code is given below please help me

my code is given below

void CclientCheckDlg::ReadFileData()
{

    char *readfilename= configfilepath ;
    //FILE *fp=fopen(readfilename ,"r");
    std::ifstream openFile(readfilename,std::ios::out | std::ios::binary);
    //string s;
    unsigned char c;
    //std::string s;

    int i=0;
    do
    {
        c=openFile.get();
        if(c==EOF||i==999)
            break;

        unsignedCharPointer[i]=c;
        i++;
        printf("%c",c);
    }while(!openFile.eof());
    //fclose(fp);
    CString cs(unsignedCharPointer);
    OutputDebugString(cs);
//  configArrStr=s.c_str();
    int begin=m_rich_edit.GetTextLength();
    m_rich_edit.SetSel(begin,begin);
//  CA2CT ct(unsignedCharPointer);
    lpctstr=(LPCTSTR)unsignedCharPointer;
    OutputDebugString(lpctstr);
    m_rich_edit.ReplaceSel(cs);
}

so please can anyone help me,how can i display null character?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2025-01-08 05:51:02
//function to read binary file(Unicode) and write to richedit2

    void function()
    {   
    CFile cFile(TEXT("edit.moc"), CFile::modeRead);
       EDITSTREAM es={0};

        //HWND hwnd=getwin
       OutputDebugStringA("........... OnBnClickedButton1() ");
       es.pfnCallback= &EditStreamCallBack; 
       es.dwCookie = (DWORD) &cFile;
       m_richEdit.StreamIn(SF_TEXT, es);
       LRESULT result = SendMessageA(::GetDlgItem(hwnd, IDC_RICHEDIT21),EM_STREAMIN,SF_TEXT,(LPARAM)&es);
    }


    //callback function, declared in header file
    DWORD CALLBACK EditStreamCallBack(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
    {
        //MessageBoxA(L"hi...1");
         OutputDebugStringA("........... OnBnClickedButton1() 2");
       CFile* pFile = (CFile*) dwCookie;

       *pcb = pFile->Read(pbBuff, cb);

       return 0;
    }

谢谢大家。

//function to read binary file(Unicode) and write to richedit2

    void function()
    {   
    CFile cFile(TEXT("edit.moc"), CFile::modeRead);
       EDITSTREAM es={0};

        //HWND hwnd=getwin
       OutputDebugStringA("........... OnBnClickedButton1() ");
       es.pfnCallback= &EditStreamCallBack; 
       es.dwCookie = (DWORD) &cFile;
       m_richEdit.StreamIn(SF_TEXT, es);
       LRESULT result = SendMessageA(::GetDlgItem(hwnd, IDC_RICHEDIT21),EM_STREAMIN,SF_TEXT,(LPARAM)&es);
    }


    //callback function, declared in header file
    DWORD CALLBACK EditStreamCallBack(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
    {
        //MessageBoxA(L"hi...1");
         OutputDebugStringA("........... OnBnClickedButton1() 2");
       CFile* pFile = (CFile*) dwCookie;

       *pcb = pFile->Read(pbBuff, cb);

       return 0;
    }

Thank you all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文