BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TPrinter with network printer

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL)
View previous topic :: View next topic  
Author Message
Daniel Iwan
Guest





PostPosted: Tue Jun 08, 2004 6:40 am    Post subject: TPrinter with network printer Reply with quote



Hello everyone!

I have a problem with using TCanvas Printer and network printer HP
LaserJet
It print just first page and throws blank all the rest.
WinNT with Borland Builder 5.

All works fine with my HP 3820 with USB printer (WinXP). It prints
correctly under debugger (step by step). Problems with buffering?


I pasted my code.

//------------------------------
void __fastcall ThPrintChart::Execute()
{
if( MessageBox(0,"Print ?", "Text", MB_YESNO | MB_ICONQUESTION) ==
IDYES)
{ Printer()->Orientation = poLandscape;
Printer()->Title = "Title";
int iPrinterH = Printer()->PageHeight;
int iPrinterW = Printer()->PageWidth;
int iSizeW = iPrinterW - 1;
int iSizeH = iPrinterH - 1;


PrinterRect = Rect( 0, 0, iSizeW, iSizeH);
PrinterCanvas = Printer()->Canvas;
PageCanvas = PageImage->Canvas;
AnsiString sFileName;


Printer()->BeginDoc();
while(*bStop != true)
{ try
{
if(!bPrintToFile)
DisplayIt();
if((!bPrintToFile) && Printer()->Printing)
{

PrinterCanvas->CopyMode = cmSrcCopy;
PrinterCanvas->CopyRect( PrinterRect, PageCanvas,
pRect->PageRect);

}
else
{
sFileName = IntToStr(pChartInfo->iActivePage) + ".bmp";
PageImage->Picture->SaveToFile(sFileName);
}
if((pChartInfo->iActivePage) >= (pChartInfo->iPageCount))
*bStop = true;
else
{
if(!bPrintToFile )
Printer()->NewPage();

ScrollIt();
}
}
catch(Exception& EPrinter)
{
}
} if(!bPrintToFile) Printer()->EndDoc(); //08.04.2004
}

PageImage->Visible = false;
}

//---------------------------------------------------------------------------
void __fastcall ThPrintChart::DisplayIt(void)
{
PageImage->Canvas->CopyMode = cmWhiteness;
PageImage->Canvas->CopyRect( pRect->PageRect, PageImage->Canvas,
pRect->PageRect);

PageImage->Visible = false;
ChartView->PrintPartialCanvas( PageImage->Canvas, pRect->ChartRect);

PageImage->Canvas->TextOut(pText->iTextLeft, pText->iTextBottom,
pText->sText1);
PageImage->Canvas->TextOut(pText->iTextLeft, pText->iTextBottom +
pText->iSize, pText->sText2);
PageImage->Canvas->TextOut(pText->iTextLeft, pText->iTextBottom +
2*pText->iSize, pText->sText3);

pText->sText4 = IntToStr(pChartInfo->iActivePage +
pChartInfo->iFirstPage - 1) + " (";
pText->sText4 += IntToStr(pChartInfo->iMaxPage);
pText->sText4 += ")";
PageImage->Canvas->TextOut(pText->iTextLeft, pText->iTextBottom +
3*pText->iSize, pText->sText4);
PageImage->Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall ThPrintChart::ScrollIt(void)
{
pChartInfo->iActivePage = pChartInfo->iActivePage + 1; //13.04.2004
ChartView->BottomAxis->Scroll(pChartInfo->iSamplesPerPage, false);
}
//---------------------------------------------------------------------------

It sometimes works better when I add two Sleep(1000); lines before and
after CopyRect line...

Any suggestions? Thank you for your answers
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.