Rendering the Server Item
When the container application asks the server to render the document, the server invokes the virtual OnDraw() method in the COleServerItem class. The COleServerItem::OnDraw() takes a device context and a size parameter, and the device context is typically a metafile DC. The viewport contains a DrawMetafile() method that draws the contents of the model to a metafile. The DrawMetafile() method excludes the grid, page boundary lines, and selection handles from being drawn, since these are artifacts used to edit objects on the canvas.
Example 27 – Rendering a server item
BOOL CMyAppSrvrItem::OnDraw(CDC* pDC, CSize& rSize)
{
// Remove this if you use rSize
UNREFERENCED_PARAMETER(rSize);
//
// Draw the viewport onto the metafile DC
//
CMyAppViewport* pViewport = GetViewport();
if (pViewport != NULL)
{
pDC->SetMapMode(MM_TEXT);
pViewport->DrawMetafile(pDC);
pDC->SetWindowExt(1,1);
}
return TRUE;
}