Question

In a MFC SDI application containing a single CView, I pass the output device context pDC->m_hDC to a mapping library to render the map within the CMyView::OnDraw() method.

I would like the rendered image to appear in the centre of the cview surrounded by a black background, i.e. the image size would be smaller than the CView client rect size. I have experimented with CDC::SetViewportOrg() and set the device size in the mapping library, however unfortunately the mapping library draws outside of the device size set.

What is the best way of limiting the image to the desired size? Should I be looking at clipping functions? Or do I have to manually draw over the undesired parts of the image.

Was it helpful?

Solution

Well you can do it 2 ways.

1) You could SetBoundsRect to the boundaries you want.
2) You could just bit blt the section of the image you want into the DC.

Method 2 would be my preferred method as there is no extra logic. It only ever even tries to draw the part you are blitting :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top