![]() |
How to draw Markup with CMetaFileDC? |
Post Reply
|
| Author | |
WindFlashing
Groupie
Joined: 21 March 2006 Status: Offline Points: 15 |
Post Options
Thanks(0)
Quote Reply
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.
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
WindFlashing
Groupie
Joined: 21 March 2006 Status: Offline Points: 15 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 July 2008 at 7:11am |
|
Hi oleg, it works great!
thanks!
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |