formviewView.cpp
上传用户:hjw22cn
上传日期:2007-01-11
资源大小:192k
文件大小:5k
- // formviewView.cpp : implementation of the CFormviewView class
- //
- #include "stdafx.h"
- #include "formview.h"
- #include "formviewDoc.h"
- #include "formviewView.h"
- #include "SheetInDlg.h"
- #include "TabDataSheet.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CFormviewView
- IMPLEMENT_DYNCREATE(CFormviewView, CFormView)
- BEGIN_MESSAGE_MAP(CFormviewView, CFormView)
- //{{AFX_MSG_MAP(CFormviewView)
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CFormviewView construction/destruction
- CFormviewView::CFormviewView()
- : CFormView(CFormviewView::IDD)
- {
- //{{AFX_DATA_INIT(CFormviewView)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- m_pSheet = NULL;
- }
- CFormviewView::~CFormviewView()
- {
- }
- void CFormviewView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CFormviewView)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BOOL CFormviewView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CFormView::PreCreateWindow(cs);
- }
- void CFormviewView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- CreateDataSheet(0);
- MoveWindow(0,0,640,480);
- GetParentFrame()->RecalcLayout();
- //ResizeParentToFit();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CFormviewView printing
- BOOL CFormviewView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CFormviewView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CFormviewView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- void CFormviewView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
- {
- // TODO: add customized printing code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CFormviewView diagnostics
- #ifdef _DEBUG
- void CFormviewView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CFormviewView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- CFormviewDoc* CFormviewView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFormviewDoc)));
- return (CFormviewDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CFormviewView message handlers
- //-----------------------------------------------------------------------------/
- // NAME: CStatusMgrDlg::DeleteDataSheet()
- //
- // PURPOSE: Deletes the property sheet object.
- //
- // PARAMETERS: None
- //
- // RETURNS: None
- //-----------------------------------------------------------------------------/
- void CFormviewView::DeleteDataSheet()
- {
- TRACE("CDlgPHCA::DeleteDataSheet()n");
- if (m_pSheet != NULL)
- {
- delete m_pSheet;
- m_pSheet = NULL;
- }
- }
- //-----------------------------------------------------------------------------/
- // NAME: CStatusMgrDlg::CreateDataSheet()
- //
- // PURPOSE: Creates the propertysheet object.
- //
- // PARAMETERS: int selectedPage The page to set active when the sheet is
- // created. A page MUST be added to the sheet
- // in the sheet constructor or the program will
- // assert (or crash).
- //
- // RETURNS: None
- //-----------------------------------------------------------------------------/
- void CFormviewView::CreateDataSheet(int selectedPage)
- {
- DeleteDataSheet();
- m_pSheet = new CTabDataSheet((UINT)IDD, this, selectedPage);
- if (m_pSheet != NULL)
- {
- CreateDlgSheet(this, m_pSheet);
- MoveDlgSheet(this, m_pSheet, IDC_SHEETFRAME);
- }
- else
- {
- MessageBeep(0);
- }
- }
- void CFormviewView::OnSize(UINT nType, int cx, int cy)
- {
- CFormView::OnSize(nType, cx, cy);
-
- if (m_pSheet)
- {
- CRect rect;
- CWnd* pWndNewArea = GetDlgItem(IDC_SHEETFRAME);
- GetClientRect(&rect);
- // These values pretty much eliminate the tab border when you turn off
- // the border style for the list control on the IDD_TABPAGE dialog
- // template. They move the "client" rectangle size out beyond the
- // borders of the window without causing the window itself to generate
- // scrollbars. This is a good thing because we ony want the scroll
- // bars from the list control anyway. We could probably do the same
- // thing for tabbed tree form views as well.
- rect.top -= 7;
- rect.left -= 9;
- rect.bottom += 10;
- rect.right += 10;
- MoveDlgSheet(this, m_pSheet, rect);
- }
- }