![]() ![]() |
||
Steps: 1. Create a new background class CMyBackShape that uses CFOBackShape as base class. 2. Loading a image file and draw the new background with codes: void CMyBackShape::OnDrawBack(CDC *pDC,const CRect &rcClip) { CFOBackShape::OnDrawBack(pDC,rcClip); CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap* pOldBitmap = memDC.SelectObject(&m_Bitmap); CRect rcBound = m_pModel->GetPagePosition(); if(!pDC->IsPrinting()) { pDC->StretchBlt(rcBound.left, rcBound.top, m_nImageWidth, m_nImageHeight, &memDC, 0,0, m_nImageWidth, m_nImageHeight, SRCCOPY ); } else { SetStretchBltMode( pDC->m_hDC, HALFTONE); FOBitmapPrint(pDC,(HBITMAP)m_Bitmap, 24, rcBound.left, rcBound.top, m_nImageWidth, m_nImageHeight); } memDC.SelectObject(pOldBitmap); memDC.DeleteDC(); } 3. Replace the default background: void CExtDataModel::DoInitData() { CFODataModel::DoInitData(); //FOTO:Add you code here. SetBackDrawComp(new CMyBackShape); } 4. Drawing flags on the canvas: void CTestMapView::OnIn1() { // TODO: Add your command handler code here if(m_drawshape == FO_COMP_COMPOSITE && m_nCurShapeResID == IDR_COMPSRES1) { m_action_state = State_SelectNone; m_drawshape = FO_COMP_NONE; FOSetSystemCursor(IDC_ARROW); return; } StartCustomShapeID(IDR_COMPSRES1); } void CTestMapView::OnUpdateIn1(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here BOOL bDesign = GetCurrentModel()->IsDesignMode(); pCmdUI->Enable(bDesign); pCmdUI->SetCheck(m_drawshape == FO_COMP_COMPOSITE && m_nCurShapeResID == IDR_COMPSRES1); } void CTestMapView::OnIn2() { // TODO: Add your command handler code here if(m_drawshape == FO_COMP_COMPOSITE && m_nCurShapeResID == IDR_COMPSRES2) { m_action_state = State_SelectNone; m_drawshape = FO_COMP_NONE; FOSetSystemCursor(IDC_ARROW); return; } StartCustomShapeID(IDR_COMPSRES2); } void CTestMapView::OnUpdateIn2(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here BOOL bDesign = GetCurrentModel()->IsDesignMode(); pCmdUI->Enable(bDesign); pCmdUI->SetCheck(m_drawshape == FO_COMP_COMPOSITE && m_nCurShapeResID == IDR_COMPSRES2); } |
Copyright ?1998-2007 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.
Please direct your questions or comments to webmaster@ucancode.com