Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to draw Markup with CMetaFileDC?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to draw Markup with CMetaFileDC?

 Post Reply Post Reply
Author
Message
WindFlashing View Drop Down
Groupie
Groupie


Joined: 21 March 2006
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindFlashing Quote  Post ReplyReply Direct Link To This Post Topic: How to draw Markup with CMetaFileDC?
    Posted: 08 July 2008 at 4:25am

I want to draw Markup with CMetaFileDC in CDocObjectServerItem::OnDraw(CDC* pDC, CSize& rSize), but it fails to render.

BOOL CMySrvrItem::OnDraw(CDC* pDC, CSize& rSize)
{
 if (!pDC)
  return FALSE;
 // Remove this if you use rSize
 UNREFERENCED_PARAMETER(rSize);
 // TODO: set mapping mode and extent
 //  (The extent is usually the same as the size returned from OnGetExtent)
 pDC->SetMapMode(MM_ANISOTROPIC);
 pDC->SetWindowOrg(0,0);
 pDC->SetWindowExt(3000, 3000);
 // TODO: add drawing code here.  Optionally, fill in the HIMETRIC extent.
 //  All drawing takes place in the metafile device context (pDC).
 if (m_pUIElement)
 {
  CXTPMarkupDrawingContext dc(pDC->m_hDC);
  CRect rc(0, 0, 3000, 3000);
  m_pUIElement->Measure(&dc, rc.Size());
  m_pUIElement->Arrange(rc);
  m_pUIElement->Render(&dc);
 }
 return TRUE;
}
 
Please help me.
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 6:21am
Hi,
 
You can Render it to Buffer DC and then stretch to pDC:
 
 
BOOL CDocSrvrItem::OnDraw(CDC* pDC, CSize& rSize)
{
 // Remove this if you use rSize
 UNREFERENCED_PARAMETER(rSize);
 CDocDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 // TODO: set mapping mode and extent
 //  (The extent is usually the same as the size returned from OnGetExtent)
 pDC->SetMapMode(MM_TEXT);
 pDC->SetWindowOrg(0,0);
 pDC->SetWindowExt(3000, 3000);
 
 CXTPMarkupContext* pContext = XTPMarkupCreateContext(0);
 
 CXTPMarkupUIElement* pElement = XTPMarkupParseText(pContext, _T("<Ellipse Stroke='Yellow' StrokeThickness='3' Fill='Blue' Width='100' Height='100'/>"));
 
 XTPMarkupMeasureElement(pElement, 100, 100);
 
 CWindowDC dcWindow(0);
 CDC dc;
 dc.CreateCompatibleDC(&dcWindow);
 
 CBitmap bmp;
 bmp.CreateCompatibleBitmap(&dcWindow, 100, 100);
 
 CBitmap* pOldBitmap = dc.SelectObject(&bmp);
 
 dc.FillSolidRect(0, 0, 100, 100, 0xFF);
 
 if (pElement)
 {
  XTPMarkupRenderElement(pElement, dc, CRect(0, 0, 100, 100));
  
  XTPMarkupReleaseElement(pElement);
 }
 
 pDC->StretchBlt(0, 0, 100, 100, &dc, 0, 0, 100, 100, SRCCOPY);
 
 
 dc.SelectObject(pOldBitmap);
 XTPMarkupReleaseContext(pContext);

 return TRUE;
}
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
WindFlashing View Drop Down
Groupie
Groupie


Joined: 21 March 2006
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindFlashing Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 7:11am

Hi oleg,

   it works great!
 
   thanks!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.