home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------
- // Copyright @ 1997 TCK Software, Incorporated
- // All Rights Reserved
- // -------------------------------------------------------------------------
- // vfTestView.cpp : implementation of the CVfTestView class
- //
-
- #include "stdafx.h"
- #include "vfTest.h"
-
- #include "vfTestDoc.h"
- #include "vfTestView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define IDC_VFORM 100
- #define IDC_VFORM2 101
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfTestView
-
- IMPLEMENT_DYNCREATE(CVfTestView, CView)
-
- BEGIN_MESSAGE_MAP(CVfTestView, CView)
- //{{AFX_MSG_MAP(CVfTestView)
- 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()
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfTestView construction/destruction
-
- CVfTestView::CVfTestView()
- {
- // TODO: add construction code here
-
- }
-
- CVfTestView::~CVfTestView()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfTestView drawing
-
- void CVfTestView::OnDraw(CDC* pDC)
- {
- CVfTestDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfTestView printing
-
- BOOL CVfTestView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- return m_vForm.DoPreparePrinting(this, pInfo);
- // return DoPreparePrinting(pInfo);
- }
-
- void CVfTestView::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_vForm.CalcPageInfo(pDC, pInfo);
- }
-
- void CVfTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfTestView diagnostics
-
- #ifdef _DEBUG
- void CVfTestView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CVfTestView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CVfTestDoc* CVfTestView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVfTestDoc)));
- return (CVfTestDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- void CVfTestView::ResetPalette()
- {
- m_palMsgHandler.DoRealizePalette(TRUE);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CVfTestView message handlers
-
- int CVfTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- int rc;
- CRect rect(10, 10, 400, 400);
-
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- m_vForm.SetPalMH(&m_palMsgHandler);
- rc = m_vForm.Create(_T("VForm"), rect, this, IDC_VFORM);
- if(!rc)
- MessageBox(_T("Could not create VForm"), _T("Error"));
-
- /* ---- Example of creating 2 VForms in same window ---
- m_vForm.Register();
- rc = m_vForm.CreateEx(WS_EX_CLIENTEDGE,
- m_vForm.ClassName(), _T("VForm"),
- WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL,
- 10, 10, 400, 400,
- this->GetSafeHwnd(),(HMENU)IDC_VFORM);
-
-
- rc = m_vForm2.CreateEx(WS_EX_CLIENTEDGE,
- m_vForm.ClassName(), _T("VForm2"),
- WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL,
- 415, 10, 400, 340,
- this->GetSafeHwnd(),(HMENU)IDC_VFORM2);
- if(!rc)
- MessageBox(_T("Could not create form 2"), _T("Error"));
- */
- return 0;
- }
-
-
- // -------------------------------------------------------------------------
- // OnEraseBkgnd - overridden to draw gray background where VForm does not fit
- // on the bottom -> VForm will always be a row heigh multiple + header and
- // footer height. If the window height is not on one of these multiples, a
- // small area will be displayed below the footer.
- // This just makes that area gray.
- // -------------------------------------------------------------------------
- BOOL CVfTestView::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 CVfTestView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
-
- m_vForm.ResizeToParent();
- }
-
- void CVfTestView::OnSetFocus(CWnd* pOldWnd)
- {
- // CView::OnSetFocus(pOldWnd);
- m_vForm.SetFocus();
- }
-
- void CVfTestView::OnInitialUpdate()
- {
- CView::OnInitialUpdate();
- VBitmap* pBmp = m_vForm.GetBmp();
- if (pBmp)
- {
- if (!m_palMsgHandler.IsHooked())
- m_palMsgHandler.Install(this, pBmp->GetPalette());
-
- // The following line is required because MFC does not send
- // WM_INITIALUPDATE through normal channels. Only realize in
- // foreground if I have the focus (could be updating all views
- // from OnFontChange)
- m_palMsgHandler.DoRealizePalette(m_hWnd==::GetFocus());
- }
- }
-
- BOOL CVfTestView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- return CView::OnNotify(wParam, lParam, pResult);
- }
-
- void CVfTestView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
- {
- CView::OnPrepareDC(pDC, pInfo);
- m_vForm.DoPrepareDC(pDC, pInfo);
- }
-
- void CVfTestView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
- {
- m_vForm.DoPrint(pDC, pInfo);
- // CView::OnPrint(pDC, pInfo);
- }
-
- void CVfTestView::OnFilePrintScreen()
- {
- m_vForm.PrintStyle(VFPRINT_SCREEN);
- CView::OnFilePrintPreview();
- }
-
- void CVfTestView::OnFilePrintAll()
- {
- m_vForm.PrintStyle(VFPRINT_ALL);
- CView::OnFilePrintPreview();
- }
-
- void CVfTestView::OnFilePrintSelected()
- {
- m_vForm.PrintStyle(VFPRINT_SELECTED);
- CView::OnFilePrintPreview();
- }
-