?? printerinfoex.cpp
字號(hào):
// PrinterInfoEx.cpp: implementation of the CPrinterInfoEx class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PrinterInfoEx.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CPrinterInfoEx::CPrinterInfoEx()
{
m_pDC = NULL;
}
CPrinterInfoEx::~CPrinterInfoEx()
{
}
BOOL CPrinterInfoEx::Init( CDC * pDC )
{
m_pDC = NULL;
m_continueNextPage = FALSE;
if( pDC == NULL )
{
return FALSE;
}
if( !pDC->IsPrinting() )
{
return FALSE;
}
m_pDC = pDC;
// 1米 = 39.37008英寸
m_xResolution = long(pDC->GetDeviceCaps( LOGPIXELSX ) * 39.37008);
m_yResolution = long(pDC->GetDeviceCaps( LOGPIXELSY ) * 39.37008);
if( m_xResolution <= 0 )
{
m_xResolution = long(300 * 39.37008);
}
if( m_yResolution <= 0 )
{
m_xResolution = m_xResolution;
}
m_paperWidth = pDC->GetDeviceCaps( HORZSIZE ) * 10;
m_paperHeight = pDC->GetDeviceCaps( VERTSIZE ) * 10;
m_widthPixel = pDC->GetDeviceCaps( HORZRES );
m_heightPixel = pDC->GetDeviceCaps( VERTRES );
m_printRect = CRect( 0, 0, m_widthPixel, m_heightPixel );
return TRUE;
}
void CPrinterInfoEx::ConvertPixelToReal(long & x, long & y)
{
ASSERT( m_pDC != NULL );
double piX = x;
double piY = y;
//注意:resolution單位是點(diǎn)/米
piX *= 10000;
x = long(piX / m_xResolution);
piY *= 10000;
y = long(piY / m_yResolution);
}
void CPrinterInfoEx::ConvertRealToPixel(long & x, long & y)
{
ASSERT( m_pDC != NULL );
double realX = x;
double realY = y;
//注意:resolution單位是點(diǎn)/米
realX /= 10000;
x = long(realX * m_xResolution);
realY /= 10000;
y = long(realY * m_yResolution);
}
BOOL CPrinterInfoEx::CanPrint()
{
if( m_pDC == NULL )
{
return FALSE;
}
if( m_printRect.top >= m_printRect.bottom
|| m_printRect.left >= m_printRect.right )
{//無(wú)可用打印范圍
return FALSE;
}
return TRUE;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -