HDC GetPrinterDC()
{
PRINTDLG prtDlg;
ZeroMemory( & prtDlg, sizeof( PRINTDLG ));
prtDlg.lStructSize = sizeof( PRINTDLG );
prtDlg.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
::PrintDlg( & prtDlg );
return prtDlg.hDC;
}
void InitDocinfo( DOCINFO * pDi, LPCTSTR lpDocName )
{
ZeroMemory( pDi, sizeof( DOCINFO ));
pDi->cbSize = sizeof( DOCINFO );
pDi->lpszDocName = lpDocName;
}
DWORD WINAPI StartPrint( LPVOID lpVoid )
{
CDDRWindow * pWnd = ( CDDRWindow * ) lpVoid;
while( TRUE )
{
EnterCriticalSection( &( pWnd->m_crtical ));
if( pWnd->m_bIsRuning )
{
while( ! ( pWnd->m_prtLst.IsEmpty()))
{
HDC hDC = GetPrinterDC(); // Get Printer DC
if( hDC != NULL )
{
DOCINFO di;
InitDocinfo( & di, _T("Palette Doc"));
StartDoc( hDC, &di );
StartPage( hDC );
pWnd->m_prtLst.GetHead()->Print( hDC ); // Print First in List
EndPage( hDC );
EndDoc( hDC );
DeleteDC( hDC );
}
pWnd->m_prtLst.RemoveHead();
}
}
else
{
LeaveCriticalSection( &( pWnd->m_crtical ));
return 0;
}
LeaveCriticalSection( &( pWnd->m_crtical ));
Sleep( 100 );
}
return 0;
}
CMovingPane::Print( HDC hdc )
{
HDC hdcSurface;
int pwidth = GetDeviceCaps( hdc, HORZRES );
int pheight = GetDeviceCaps( hdc, VERTRES );
int width = pwidth;
int height = pheight;
if( width >= 600 )
width -= 400;
if( height >= 600 )
height -= 400;
float blS = ( float ) (( float ) m_Surface.GetWidth() / ( float ) m_Surface.GetHeight());
int cx, cy;
cx = width;
cy = ( int ) (( float ) width / blS );
if( cy >= height )
{
cy = height;
cx = ( int ) ( height * blS );
}
int x = (( pwidth - cx ) / 2 );
int y = (( pheight - cy ) / 2 );
if( m_Surface.GetDirectSurface()->GetDC( & hdcSurface ) == DD_OK )
{
StretchBlt( hdc, x, y, cx, cy, hdcSurface, 0, 0, m_Surface.GetWidth(), m_Surface.GetHeight(), SRCCOPY );
m_Surface.GetDirectSurface()->ReleaseDC( hdcSurface );
}
}
WIN32 Print
最新推荐文章于 2022-07-25 12:33:38 发布