home *** CD-ROM | disk | FTP | other *** search
- // vfPictView.cpp : implementation of the CVfPictView class
- //
-
- #include "stdafx.h"
- #include "vfTest.h"
-
- #include "vfTestDoc.h"
- #include "vfPictView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfPictView
-
- IMPLEMENT_DYNCREATE(CVfPictView, CView)
-
- BEGIN_MESSAGE_MAP(CVfPictView, CView)
- //{{AFX_MSG_MAP(CVfPictView)
- ON_WM_CREATE()
- ON_WM_ERASEBKGND()
- ON_WM_SETFOCUS()
- ON_WM_SIZE()
- ON_COMMAND(ID_FILE_PRINT_SCREEN, OnFilePrintScreen)
- ON_COMMAND(ID_FILE_PRINT_ALL, OnFilePrintAll)
- ON_COMMAND(ID_FILE_PRINT_SELECTED, OnFilePrintSelected)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfPictView construction/destruction
-
- CVfPictView::CVfPictView()
- {
- // TODO: add construction code here
-
- }
-
- CVfPictView::~CVfPictView()
- {
- }
-
- BOOL CVfPictView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfPictView drawing
-
- void CVfPictView::OnDraw(CDC* pDC)
- {
- CVfTestDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfPictView printing
-
- void CVfPictView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
- {
- m_pictVf.DoPrint(pDC, pInfo);
- // CView::OnPrint(pDC, pInfo);
- }
-
-
- BOOL CVfPictView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- return m_pictVf.DoPreparePrinting(this, pInfo);
- // return DoPreparePrinting(pInfo);
- }
-
- void CVfPictView::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_pictVf.CalcPageInfo(pDC, pInfo);
- }
-
- void CVfPictView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- void CVfPictView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
- {
- CView::OnPrepareDC(pDC, pInfo);
- m_pictVf.DoPrepareDC(pDC, pInfo);
- }
-
- void CVfPictView::OnFilePrintScreen()
- {
- m_pictVf.PrintStyle(VFPRINT_SCREEN);
- CView::OnFilePrintPreview();
- }
-
- void CVfPictView::OnFilePrintAll()
- {
- m_pictVf.PrintStyle(VFPRINT_ALL);
- CView::OnFilePrintPreview();
- }
-
- void CVfPictView::OnFilePrintSelected()
- {
- m_pictVf.PrintStyle(VFPRINT_SELECTED);
- CView::OnFilePrintPreview();
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfPictView diagnostics
-
- #ifdef _DEBUG
- void CVfPictView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CVfPictView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CVfTestDoc* CVfPictView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVfTestDoc)));
- return (CVfTestDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfPictView message handlers
-
- int CVfPictView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- CRect rect(10, 10, 400, 400);
- if(!m_pictVf.Create(_T("Picture VForm"), rect, this, IDC_PICTVFORM))
- AfxMessageBox(_T("Could not create VForm"));
-
- return 0;
- }
-
- BOOL CVfPictView::OnEraseBkgnd(CDC* pDC)
- {
- /* // --- Only use if using snap resize
- // --- this will cause flicker when sizing
- 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;
- // return CView::OnEraseBkgnd(pDC);
- }
-
- void CVfPictView::OnSetFocus(CWnd* pOldWnd)
- {
- CView::OnSetFocus(pOldWnd);
- // m_pictVf.SetFocus();
- }
-
- void CVfPictView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
- m_pictVf.ResizeToParent();
- }
-