// RibbonMDISampleView.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "RibbonMDISample.h" #include "RibbonMDISampleDoc.h" #include "CntrItem.h" #include "RibbonMDISampleView.h" #include "MainFrm.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRibbonMDISampleView IMPLEMENT_DYNCREATE(CRibbonMDISampleView, CRichEditView) BEGIN_MESSAGE_MAP(CRibbonMDISampleView, CRichEditView) //{{AFX_MSG_MAP(CRibbonMDISampleView) ON_WM_CREATE() ON_WM_DESTROY() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview) ON_COMMAND(ID_EDIT_PASTE, CRibbonMDISampleView::OnEmptyCommand) ON_COMMAND(ID_EDIT_CUT, CRibbonMDISampleView::OnEmptyCommand) ON_COMMAND(ID_EDIT_COPY, CRibbonMDISampleView::OnEmptyCommand) ON_COMMAND(ID_EDIT_SELECT_ALL, CRibbonMDISampleView::OnEmptyCommand) ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, CRibbonMDISampleView::OnUpdateEmptyCommand) ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, CRibbonMDISampleView::OnUpdateEmptyCommand) ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, CRibbonMDISampleView::OnUpdateEmptyCommand) ON_UPDATE_COMMAND_UI(ID_EDIT_SELECT_ALL, CRibbonMDISampleView::OnUpdateEmptyCommand) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRibbonMDISampleView construction/destruction CRibbonMDISampleView::CRibbonMDISampleView() : ParentView() { } CRibbonMDISampleView::~CRibbonMDISampleView() { } BOOL CRibbonMDISampleView::PreCreateWindow(CREATESTRUCT& cs) { if (!ParentView::PreCreateWindow(cs)) return FALSE; return TRUE; } void CRibbonMDISampleView::OnDraw(CDC* pDC) { CRibbonMDISampleDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here } int CRibbonMDISampleView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (ParentView::OnCreate(lpCreateStruct) == -1) { TRACE(_T("ERROR: Unable to create application view.\n")); return -1; } ModifyStyleEx(WS_EX_CLIENTEDGE, 0); OnThemeChanged(); return 0; } void CRibbonMDISampleView::OnEmptyCommand() { AfxMessageBox(_T("TODO: Add your command handler")); } void CRibbonMDISampleView::OnUpdateEmptyCommand(CCmdUI* pCmdUI) { _ASSERTE(NULL != pCmdUI); pCmdUI->Enable(TRUE); } void CRibbonMDISampleView::OnInitialUpdate() { ParentView::OnInitialUpdate(); // Set the printing margins (720 twips = 1/2 inch) SetMargins(CRect(720, 720, 720, 720)); if (GetDocument()->GetPathName().IsEmpty()) { HINSTANCE hInstance = AfxGetInstanceHandle(); HRSRC hRsrc = ::FindResource(hInstance, MAKEINTRESOURCE(IDR_FEEDBACK_RTF), _T("RTF")); if (NULL == hRsrc) return; HGLOBAL hGlobal = LoadResource(hInstance, hRsrc); if (NULL == hGlobal) return; LPVOID pData = LockResource(hGlobal); if (NULL == pData) return; DWORD dwSize = (DWORD)SizeofResource(hInstance, hRsrc); if (dwSize == 0) return; CMemFile memRTF(reinterpret_cast(pData), dwSize, 0); CArchive ar(&memRTF, CArchive::load | CArchive::bNoFlushOnDelete | CArchive::bNoByteSwap); Serialize(ar); GetDocument()->SetModifiedFlag(FALSE); } } ///////////////////////////////////////////////////////////////////////////// // CRibbonMDISampleView printing BOOL CRibbonMDISampleView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CRibbonMDISampleView::OnDestroy() { // It is important to deactivate the item on destruction. COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this); if (pActiveItem != NULL && pActiveItem->GetActiveView() == this) { pActiveItem->Deactivate(); _ASSERTE(GetDocument()->GetInPlaceActiveItem(this) == NULL); } ParentView::OnDestroy(); } ///////////////////////////////////////////////////////////////////////////// // CRibbonMDISampleView diagnostics #ifdef _DEBUG void CRibbonMDISampleView::AssertValid() const { CRichEditView::AssertValid(); } void CRibbonMDISampleView::Dump(CDumpContext& dc) const { CRichEditView::Dump(dc); } CRibbonMDISampleDoc* CRibbonMDISampleView::GetDocument() const { CRibbonMDISampleDoc* pDoc = DYNAMIC_DOWNCAST(CRibbonMDISampleDoc, m_pDocument); ASSERT_VALID(pDoc); return pDoc; } #endif //_DEBUG CMainFrame* CRibbonMDISampleView::GetMainFrame() const { CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); ASSERT_VALID(pMainFrame); return pMainFrame; } void CRibbonMDISampleView::OnThemeChanged() { } ///////////////////////////////////////////////////////////////////////////// // CRibbonMDISampleView message handlers