Tuesday, August 16, 2011


For printing, in c++, we need to find the printer's aspect ratio. For get the printer/monitor's aspect ratio use this function


GetAspectRatio( HDC p_hDC, int& p_nAspectX, int& p_nAspectY )
{
//p_hDC is printer's /Monitor's handle

HDC l_hScreenDC = GetDC(NULL);
p_nAspectX = GetDeviceCaps( l_hScreenDC, LOGPIXELSX ) / GetDeviceCaps( p_hDC, LOGPIXELSX );
p_nAspectY = GetDeviceCaps( l_hScreenDC, LOGPIXELSY ) / GetDeviceCaps( p_hDC, LOGPIXELSY ) ;
}