hexview.cpp

来自「文件视图,CFrameWnd C Static CRect MoveWindow」· C++ 代码 · 共 83 行

CPP
83
字号
// HexView.cpp : implementation file
//

#include "stdafx.h"
#include "NoneSplitViewBySameDoc.h"
#include "NoneSplitViewBySameDocDoc.h"
#include "HexView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHexView

IMPLEMENT_DYNCREATE(CHexView, CView)

CHexView::CHexView()
{
}

CHexView::~CHexView()
{
}


BEGIN_MESSAGE_MAP(CHexView, CView)
	//{{AFX_MSG_MAP(CHexView)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHexView drawing

void CHexView::OnDraw(CDC* pDC)
{
        CNoneSplitViewBySameDocDoc* pDoc = (CNoneSplitViewBySameDocDoc*)GetDocument();

        int        i, j, k, l, nHeight;
        long       n;
        char       temp[10];
        CString    Line;
        TEXTMETRIC tm;

        pDC->GetTextMetrics(&tm);
        nHeight = tm.tmHeight + tm.tmExternalLeading;

        j = pDoc->m_stringArray.GetSize();
        for(i = 0; i < j; i++) 
		{
            wsprintf(temp, "%02x     ", i);
            Line = temp;
            l = pDoc->m_stringArray[i].GetLength();//得到m_stringArray[i]的字节数,按字节循环
            for(k = 0; k < l; k++) {
                n = pDoc->m_stringArray[i][k] & 0x00FF;//位与操作得到m_stringArray[i][k]低字节的值
                wsprintf(temp, "%02lx ", n);
                Line += temp;
            }
            pDC->TextOut(10, i*nHeight, Line);
        }
}

/////////////////////////////////////////////////////////////////////////////
// CHexView diagnostics

#ifdef _DEBUG
void CHexView::AssertValid() const
{
	CView::AssertValid();
}

void CHexView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CHexView message handlers

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?