RibbonMDISampleView.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:4k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // RibbonMDISampleView.cpp : implementation of the CRibbonMDISampleView class
  2. //
  3. #include "stdafx.h"
  4. #include "RibbonMDISample.h"
  5. #include "RibbonMDISampleDoc.h"
  6. #include "CntrItem.h"
  7. #include "RibbonMDISampleView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CRibbonMDISampleView
  15. IMPLEMENT_DYNCREATE(CRibbonMDISampleView, CRichEditView)
  16. BEGIN_MESSAGE_MAP(CRibbonMDISampleView, CRichEditView)
  17. //{{AFX_MSG_MAP(CRibbonMDISampleView)
  18. // NOTE - the ClassWizard will add and remove mapping macros here.
  19. //    DO NOT EDIT what you see in these blocks of generated code!
  20. ON_WM_DESTROY()
  21. //}}AFX_MSG_MAP
  22. // Standard printing commands
  23. ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint)
  24. ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint)
  25. ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CRibbonMDISampleView construction/destruction
  29. CRibbonMDISampleView::CRibbonMDISampleView()
  30. {
  31. // TODO: add construction code here
  32. }
  33. CRibbonMDISampleView::~CRibbonMDISampleView()
  34. {
  35. }
  36. BOOL CRibbonMDISampleView::PreCreateWindow(CREATESTRUCT& cs)
  37. {
  38. // TODO: Modify the Window class or styles here by modifying
  39. //  the CREATESTRUCT cs
  40. return CRichEditView::PreCreateWindow(cs);
  41. }
  42. void CRibbonMDISampleView::OnInitialUpdate()
  43. {
  44. CRichEditView::OnInitialUpdate();
  45. // Set the printing margins (720 twips = 1/2 inch).
  46. SetMargins(CRect(720, 720, 720, 720));
  47. }
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CRibbonMDISampleView printing
  50. BOOL CRibbonMDISampleView::OnPreparePrinting(CPrintInfo* pInfo)
  51. {
  52. // default preparation
  53. return DoPreparePrinting(pInfo);
  54. }
  55. void CRibbonMDISampleView::OnDestroy()
  56. {
  57. // Deactivate the item on destruction; this is important
  58. // when a splitter view is being used.
  59.    CRichEditView::OnDestroy();
  60. }
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CRibbonMDISampleView diagnostics
  63. #ifdef _DEBUG
  64. void CRibbonMDISampleView::AssertValid() const
  65. {
  66. CRichEditView::AssertValid();
  67. }
  68. void CRibbonMDISampleView::Dump(CDumpContext& dc) const
  69. {
  70. CRichEditView::Dump(dc);
  71. }
  72. CRibbonMDISampleDoc* CRibbonMDISampleView::GetDocument() // non-debug version is inline
  73. {
  74. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRibbonMDISampleDoc)));
  75. return (CRibbonMDISampleDoc*)m_pDocument;
  76. }
  77. #endif //_DEBUG
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CRibbonMDISampleView message handlers
  80. void CRibbonMDISampleView::OnFilePrintPreview()
  81. {
  82. // In derived classes, implement special window handling here
  83. // Be sure to Unhook Frame Window close if hooked.
  84. // must not create this on the frame.  Must outlive this function
  85. CPrintPreviewState* pState = new CPrintPreviewState;
  86. // DoPrintPreview's return value does not necessarily indicate that
  87. // Print preview succeeded or failed, but rather what actions are necessary
  88. // at this point.  If DoPrintPreview returns TRUE, it means that
  89. // OnEndPrintPreview will be (or has already been) called and the
  90. // pState structure will be/has been deleted.
  91. // If DoPrintPreview returns FALSE, it means that OnEndPrintPreview
  92. // WILL NOT be called and that cleanup, including deleting pState
  93. // must be done here.
  94. if ( !DoPrintPreview( XTP_IDD_PREVIEW_DIALOGBAR, this,
  95. RUNTIME_CLASS( CXTPPreviewView ), pState ))
  96. {
  97. // In derived classes, reverse special window handling here for
  98. // Preview failure case
  99. TRACE0( "Error: DoPrintPreview failed.n" );
  100. AfxMessageBox( AFX_IDP_COMMAND_FAILURE );
  101. delete pState;      // preview failed to initialize, delete State now
  102. }
  103. }