FormatNumView.cpp
上传用户:lqt88888
上传日期:2009-12-14
资源大小:905k
文件大小:3k
- // FormatNumView.cpp : implementation of the CFormatNumView class
- //
- #include "stdafx.h"
- #include "FormatNum.h"
- #include "FormatNumSet.h"
- #include "FormatNumDoc.h"
- #include "FormatNumView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CFormatNumView
- IMPLEMENT_DYNCREATE(CFormatNumView, CRecordView)
- BEGIN_MESSAGE_MAP(CFormatNumView, CRecordView)
- //{{AFX_MSG_MAP(CFormatNumView)
- ON_BN_CLICKED(IDC_SHOW, OnShow)
- ON_BN_CLICKED(IDC_MODIFY, OnModify)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CFormatNumView construction/destruction
- CFormatNumView::CFormatNumView()
- : CRecordView(CFormatNumView::IDD)
- {
- //{{AFX_DATA_INIT(CFormatNumView)
- m_pSet = NULL;
- m_fNumber = 0.0;
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- }
- CFormatNumView::~CFormatNumView()
- {
- }
- void CFormatNumView::DoDataExchange(CDataExchange* pDX)
- {
- CRecordView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CFormatNumView)
- DDX_Text(pDX, IDC_NUMBER, m_fNumber);
- //}}AFX_DATA_MAP
- }
- BOOL CFormatNumView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CRecordView::PreCreateWindow(cs);
- }
- void CFormatNumView::OnInitialUpdate()
- {
- m_pSet = &GetDocument()->m_formatNumSet;
- CRecordView::OnInitialUpdate();
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CFormatNumView printing
- BOOL CFormatNumView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CFormatNumView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CFormatNumView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CFormatNumView diagnostics
- #ifdef _DEBUG
- void CFormatNumView::AssertValid() const
- {
- CRecordView::AssertValid();
- }
- void CFormatNumView::Dump(CDumpContext& dc) const
- {
- CRecordView::Dump(dc);
- }
- CFormatNumDoc* CFormatNumView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFormatNumDoc)));
- return (CFormatNumDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CFormatNumView database support
- CRecordset* CFormatNumView::OnGetRecordset()
- {
- return m_pSet;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CFormatNumView message handlers
- //显示第一条记录
- void CFormatNumView::OnShow()
- {
- double fNumber = m_pSet->m_Number;
- m_fNumber = fNumber*100;
- UpdateData(FALSE);
- }
- //修改第一条记录
- void CFormatNumView::OnModify()
- {
- UpdateData(TRUE);
- m_pSet->Edit();
- m_pSet->m_Number = m_fNumber/100;
- m_pSet->Update();
- }