The study of Programming Windows with MFC--print's example

来源:互联网 发布:java getmethod 编辑:程序博客网 时间:2024/05/01 08:59

convert RGB color values into shades of gray with this formula:

r/g/b = (red * 0.30) + (green * 0.59) + (blue * 0.11)

class CHexDoc:public CDocument
{
public:
 CHexDoc();
    DECLARE_DYNCREATE(CHexDoc)

public:
 BYTE GetBytes(UINT nIndex,UINT nCode,PVOID nBuffer);
 UINT GetDocumentLength();

public:
    virtual BOOL OnNewDocument();
    virtual void Serialize(CArchive& ar);
    virtual void DeleteContents();

public:
    virtual ~CHexDoc();

protected:
    BYTE* m_pFileData;
    UINT m_nDocLength;
    DECLARE_MESSAGE_MAP()
};


class CHexView : public CScrollView
{
protected:
    CHexView();
    DECLARE_DYNCREATE(CHexView)


public:
    CHexDoc* GetDocument();


public:
    virtual void OnDraw(CDC* pDC); 
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

protected:
    virtual void OnInitialUpdate();
    virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
    virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
    virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
    virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
  
public:
    virtual ~CHexView();

protected:
    void FormatLine(CHexDoc* pDoc, UINT nLine, CString& string);
    void PrintPageHeader(CHexDoc* pDoc, CDC* pDC, UINT nPageNumber);
    void PrintPage(CHexDoc* pDoc, CDC* pDC, UINT nPageNumber);
    UINT m_cxWidth;
    UINT m_cxOffset;
    UINT m_nLinesPerPage;
    UINT m_nLinesTotal;
    UINT m_cyPrinter;
    UINT m_cyScreen;
    CFont m_fontPrinter;
    CFont m_fontScreen;

    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

    DECLARE_MESSAGE_MAP()
};

原创粉丝点击