this is method am using can you please tell what type of initialisation is taking place and what coordinates is being used??
By the looks of it, this would be determined in the OnPrepareDC() call. A default CScrollView::OnPrepareDC() adjusts the viewport offset relative to the scroll position of the scroll view's scroll bars so coordinates are relative to a virtual "document", a section of which is visible through the client window of the view. You maybe should use CClientDC() instead of GetDC() in line 7 of your code.