469,273 Members | 1,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,273 developers. It's quick & easy.

TPrinter with network printer

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
Jul 22 '05 #1
2 3003
Daniel Iwan wrote:
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
Jul 22 '05 #2
Daniel Iwan <wi****@op.pl> spoke thus:
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.


Your post is off-topic for comp.lang.c++. Please visit

http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/

for posting guidelines and frequently asked questions. Thank you.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by KohlerTommy | last post: by
1 post views Thread by Maileen | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.