TPrinter with network printer

D

Daniel Iwan

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)


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

Sorry for my English :)


Daniel
 
S

Stephen Waits

Daniel said:
WinNT with Borland Builder 5.

Daniel,

You've posted to the wrong group.. You're more likely to get an answer
in the Borland or Win32 newsgroups.

Good luck,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,800
Messages
2,569,657
Members
45,416
Latest member
MyraTrotte
Top