已经得到一个char *数据指针和其长度,现在要对数据进行处理后输出,
要求:  格式:
        数据16进制显示   :该行数据的字符显示(不能显示字符用点)
        数据16进制显示   :该行数据的字符显示(不能显示字符用点)也就是输出的同时还要对数据进行处理,怎么用在mfc的sdi程序的视图中显示        
上面信息???我只会用printf;呵呵!
各位大虾请多帮忙!感激不尽!散分不尽!呵呵!

解决方案 »

  1.   

    在视类的OnDraw里用TextOut就行了
      

  2.   

    CString str;
    int x,y;
    for(int i = 0;i<Length;i++)
    {
       //数据处理赋值;
    }
    在OnDraw函数中,pDC->TextOut(x,y,str);
      

  3.   

    给你个例子
    在document的h文件中定义成员变量
    CStringArray m_strArray;
    在document.cpp中打开文件
    void CViewDataDoc::OnFileOpen() 
    {
    m_bFileOpened = 0;
    char* lpszFileExt = "All file(*.*)|*.*||";
    CFileDialog Dialog(TRUE,NULL,NULL,NULL,lpszFileExt,NULL);
    if(Dialog.DoModal() != IDOK) 
    return;
    else
    m_strFileName = Dialog.GetPathName(); CFile fp;
    DWORD dwFileLen = 0;
    if(!fp.Open(m_strFileName,CFile::modeRead)) return;
    dwFileLen = fp.GetLength(); BYTE* lpByte;
    lpByte = new BYTE[dwFileLen];
    if(!lpByte) return;
    fp.Read(lpByte,dwFileLen);
    fp.Close(); int nLines = dwFileLen/16 + 1;
    CString strTmp;
    for(int i=0;i<nLines-1;i++)
    {
    strTmp.Format("0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x 0x% 02x",
              lpByte[i+0],lpByte[i+1],lpByte[i+2],lpByte[i+3],lpByte[i+4],lpByte[i+5],lpByte[i+6],lpByte[i+7],
      lpByte[i+8],lpByte[i+9],lpByte[i+10],lpByte[i+11],lpByte[i+12],lpByte[i+13],lpByte[i+14],lpByte[i+15]
     );
    m_strArray.Add(strTmp);
    }
    m_bFileOpened = 1;
    }在View中显示数据
    void CViewDataView::OnDraw(CDC* pDC)
    {
    CViewDataDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    CString str;
    int n = pDoc->m_strArray.GetSize();
    int i = 0;
    while(i < n)
    {
    pDC->TextOut(20,i*20,pDoc->m_strArray.GetAt(i));
    i++;
    }
    }
      

  4.   

    在OnOpenFile的最后加上一句
    UpdateAllViews(NULL);
      

  5.   

    上面的代码有内存泄漏,需要在OnOpenFile的最后加上
    delete[] lpByte;
    lpByte = 0;