home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------
- // Copyright @ 1997 TCK Software, Incorporated
- // All Rights Reserved
- // -------------------------------------------------------------------------
-
- // VfHexView.cpp : implementation of the CVfHexView class
- //
-
- #include "stdafx.h"
- #include "VfHex.h"
-
- #include "VfHexDoc.h"
- #include "VfHexView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfHexView
-
- IMPLEMENT_DYNCREATE(CVfHexView, CView)
-
- BEGIN_MESSAGE_MAP(CVfHexView, CView)
- //{{AFX_MSG_MAP(CVfHexView)
- ON_WM_CREATE()
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_WM_SETFOCUS()
- ON_COMMAND(ID_FILE_PRINT_SCREEN, OnFilePrintScreen)
- ON_COMMAND(ID_FILE_PRINT_ALL, OnFilePrintAll)
- ON_COMMAND(ID_FILE_PRINT_SELECTED, OnFilePrintSelected)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfHexView construction/destruction
-
- CVfHexView::CVfHexView()
- {
- // TODO: add construction code here
-
- }
-
- CVfHexView::~CVfHexView()
- {
- }
-
- BOOL CVfHexView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfHexView drawing
-
- void CVfHexView::OnDraw(CDC* pDC)
- {
- CVfHexDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfHexView printing
-
- void CVfHexView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
- {
- m_vfFile.DoPrint(pDC, pInfo);
- // CView::OnPrint(pDC, pInfo);
- }
-
-
- BOOL CVfHexView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- return m_vfFile.DoPreparePrinting(this, pInfo);
- // return DoPreparePrinting(pInfo);
- }
-
- void CVfHexView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
- {
- // Set the page info again, since the user may have changed the printer since
- // we set it up in OnPreparePrinting
- m_vfFile.CalcPageInfo(pDC, pInfo);
- }
-
- void CVfHexView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- void CVfHexView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
- {
- CView::OnPrepareDC(pDC, pInfo);
- m_vfFile.DoPrepareDC(pDC, pInfo);
- }
-
- void CVfHexView::OnFilePrintScreen()
- {
- m_vfFile.PrintStyle(VFPRINT_SCREEN);
- CView::OnFilePrintPreview();
- }
-
- void CVfHexView::OnFilePrintAll()
- {
- m_vfFile.PrintStyle(VFPRINT_ALL);
- CView::OnFilePrintPreview();
- }
-
- void CVfHexView::OnFilePrintSelected()
- {
- m_vfFile.PrintStyle(VFPRINT_SELECTED);
- CView::OnFilePrintPreview();
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfHexView diagnostics
-
- #ifdef _DEBUG
- void CVfHexView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CVfHexView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CVfHexDoc* CVfHexView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVfHexDoc)));
- return (CVfHexDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfHexView message handlers
-
- int CVfHexView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- int rc;
- CRect rectFileVF;
-
- GetClientRect(rectFileVF);
- m_vfFile.AllowAdd(FALSE); // No adding of records
- m_vfFile.Init(GetDocument());
-
- rc = m_vfFile.Create("File VForm", rectFileVF, this, IDC_FILE_VFORM);
- if(!rc)
- MessageBox("Could not create File VForm", "Error");
-
- m_vfFile.SetFocus();
- return 0;
- }
-
- BOOL CVfHexView::OnEraseBkgnd(CDC* pDC)
- {
- CBrush backBrush(GetSysColor(COLOR_3DFACE));
- CBrush* pOldBrush = pDC->SelectObject(&backBrush);
-
- CRect rect;
- pDC->GetClipBox(&rect); // Erase the area needed
- pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
- pDC->SelectObject(pOldBrush);
-
- return TRUE;
- }
-
- void CVfHexView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
- m_vfFile.ResizeToParent();
- }
-
- void CVfHexView::OnSetFocus(CWnd* pOldWnd)
- {
- m_vfFile.SetFocus();
- }
-
- void CVfHexView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
- {
- CVfHexDoc *pDoc = GetDocument();
- long nRecCount = pDoc->RecCountHigh();
- int nRecSize = pDoc->RecSize();
- m_vfFile.ResetWidth(nRecSize);
- m_vfFile.ResetNumRows(nRecCount);
- // m_vfFile.RefreshData(); // refresh current rows data
- }
-
-
- void CVfHexView::OnInitialUpdate()
- {
- static BOOL bFirst = TRUE;
-
- CView::OnInitialUpdate();
-
- if(bFirst)
- {
- bFirst = FALSE;
- CVfHexDoc *pDoc = GetDocument();
- pDoc->InitTB(); // Initialize toolbar controls
- }
- }
-
-