<< Return to Main Index

< Return to Class Index

CGXGridCore::OnAdjustPrintRectangle

virtual void OnAdjustPrintRectangle(CDC* pDC, CPrintInfo* pInfo);?

pDC

Points to the printer device context.

pInfo

Points to a CPrintInfo structure that describes the current print job.

Remarks

Called by OnGridPrint or OnGridBeginPrinting to determine the drawing rectangle for the grid on the page.

The default implementation retrieves the margin settings stored in the property object and subtracts them from the pInfo->m_rectDraw rectangle.

NOTE: If the user margins are NOT adjusted for the printer's non-printable areas, then the resulting margins may be off slightly.

One possible solution is to query the margins non-printable areas through GetDeviceCaps.
PHYSICALWIDTH returns the paper width, HORZRES returns printable area width and PHYSICALOFFSETX returns non-printable margin on the left.
NOTE that EACH of the above are returned as device units.

For example, to convert the non-printable margins from the right margin from device units to logical units, subtract HORZRES and PHYSICALOFFSETX from PHYSICALWIDTH.
Similar calculations need to be applied for the left, top and bottom non-printable margins as required by the application.

Conversion of these printing rectangles, calculated by the printing framework from device units to logical units, should be performed here in OnAdjustPrintRectangle().

See Also

CGXProperties::GetMargins CGXGridCore::OnGridPrint CGXGridCore::OnGridBeginPrinting

CGXGridCore

Class Overview | Class Members