Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help a noob:(

Status
Not open for further replies.

zwq

Programmer
Aug 2, 2010
2
RO
I have a problem with the Print() and PrintDialog().
I have a form with a vertical ScrollBar.

...
if(PrintDialog1->Execute())
{
File1->Visible=False;
Form20->VertScrollBar->Position=0;
Form20->Print;
File1->Visible=True;
}
...

This code print me only the visible part of form (700/1000 pixel).How can I print all the form without changing the height of the form?
Thank you.
 
I've not used the print dialog in a long time but it you might want to set the FromPage, ToPage, and PrintRange. The following code is from the BCB6 help file:
Code:
void __fastcall TForm1::Button1Click(TObject *Sender)

{
  PrintDialog1->Options.Clear();
  PrintDialog1->Options << poPageNums << poSelection;
  PrintDialog1->FromPage = 1;
  PrintDialog1->MinPage = 1;
  PrintDialog1->ToPage = PageControl1->PageCount;
  PrintDialog1->MaxPage = PageControl1->PageCount;
  if (PrintDialog1->Execute())
  {
    int Start, Stop;
    // determine the range the user wants to print
    switch (PrintDialog1->PrintRange)
    {
      case prSelection:

        Start = PageControl1->ActivePage->PageIndex;
        Stop = Start;
        break;
      case prPageNums:
        Start = PrintDialog1->FromPage - 1;
        Stop =  PrintDialog1->ToPage - 1;
        break;
      default:  // prAllPages
        Start = PrintDialog1->MinPage - 1;
        Stop = PrintDialog1->MaxPage - 1;
        break;
    }
    // now, print the pages 
    Printer()->BeginDoc();
    for (int i = Start; i <= Stop; i++)

    {
      PageControl1->Pages[i]->PaintTo(Printer()->Handle, 10, 10);
      if (i != Stop)
        Printer()->NewPage();
    }
    Printer()->EndDoc();
  }
}


James P. Cottingham
I'm number 1,229!
I'm number 1,229!
 
thank you very much for the replay.
That code i think is for more then one pages.
For anyone who has this problem I found a tricky solve:D

if(PrintDialog1->Execute())
{
File1->Visible=False;
Form20->VertScrollBar->Position=0;
Form20->AutoScroll=false;
Form20->BorderStyle=bsNone;
Form20->Height=1000;
Form20->Width=805;
Form20->Print();
Form20->Height=700;
Form20->Width=805;
Form20->BorderStyle=bsSizeable;
Form20->AutoScroll=true;
File1->Visible=True;
}

What's the trick: Form20->BorderStyle=bsSizeable; (by default) dosen't let you set a hight larger then resolution (for example: if you set the resolution 1152x864,you can set to form a maxim height 864).But if BorderStyle=bsNone you can set what height you want.And this little trick isn't so visible in application:) Thank you for your support.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top