tags:

views:

22

answers:

1

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.

+1  A: 

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 :)

Goz
Many thanks. In the end my solution was to reduce the size of the SDI view (not exactly what I asked, I know). This page was useful: http://www.codeproject.com/KB/docview/SmallerSDIView.aspx
Ham