home Tech Library Tech Forum
Publisher
 
The Document View Architecture        
 
 
The Function OnPrepareDC()
 
 

 

To draw graphics, we need to provide scale factors, and we need to change the mapping mode from the default value, which is MM_TEXT. This can be done in the CView::OnPrepareDC() function. The OnPrepareDC() function is called for OnPaint(), for OnDraw(), and for OnPrint(). The OnPrepareDC() function is called in OnPaint() immediately before the call to OnDraw(). The mapping mode is set before painting the view. If you are printing, the same OnPrepareDC() function is called, this time immediately before the application framework calls OnPrint(). The mapping mode is set before the printing of the page. We want to change the mapping mode only if we are printing, so we will call the CDC::IsPrinting() function and if we are printing, we will then override the function and change the mapping mode.

The function OnPrepareDC() has two parameters. The first is the device context. The second parameter is a pointer to a CPrintInfo structure, which is valid only if OnPrepareDC() is being called prior to printing. Test for this condition by calling the CDC function, IsPrinting().
 
     
   
  RELATED TOPICS  
Document-View Architecture
Message Routing
PreCreateWindow() Function
OnDraw() Function
Document Template
RUNTIME_CLASS Macro
CView Class
Print from the View
Mapping Modes
Serialization using CArchive class
Diagnostic Helpers
 


 
           
Home | Profile | Users | Library | Publisher | Tech Forum | News | Contact Us