PrintPreview Problem. Bug or ?- Updated Please Read Inside

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

PrintPreview Problem. Bug or ?- Updated Please Read Inside

Postby salpay » March 8th, 2005, 8:00 am

I downloaded PreviewSuit 4.60 and compiled "General Demo", Preview works fine but when i send this preview to printer , all output pages clipped some from the bottom of the pages. So the output and preview becomes different from each others. (For both inkjets and laser printers).
Finally, i realized that the problem comes from "SetPrinterOptions" Code.
In this Code, Printer PaperSize is set for only if (ActiveForm = '') or (Win32Platform <> VER_PLATFORM_WIN32_NT). But if you have already selected a paper (means ActiveForm and papersize), printer papersize is not set and the problem occurs.
So I made a modification in the "SetPrinterOptions" routine below;

Replace:
if (ActiveForm = '') or (Win32Platform <> VER_PLATFORM_WIN32_NT) then
begin
...........................
...........................
end;

With:
if (ActiveForm = '') or (Win32Platform <> VER_PLATFORM_WIN32_NT) then
begin
...........................
...........................
end
else
begin
dmFields := dmFields or DM_PAPERSIZE;
DmPaperSize := PaperSizes[FPaperType].ID;
end;

---------------------------------------------------------------------------------
The important point is that you have to assign correct value to FpaperType after changing activeform (new papertype and also papersize) before printing. So you can do this easly by using the code below:

with printpreview do
begin
PaperType:=TpaperType( NewPaperID ); // NewPaperId:=9 for A4 Form
end;

For general demo, this code should be;

procedure TPreviewForm.FormComboBoxChange(Sender: TObject);
begin
with PrintPreview do
begin
if FormComboBox.ItemIndex >= 0 then
FormName := FormComboBox.Items[FormComboBox.ItemIndex];
PaperType:=TpaperType(FormComboBox.ItemIndex);
end;


Now, Everyting works fine for me.


Salpay.
salpay
Member
Member
 
Posts: 1
Joined: March 7th, 2005, 10:00 am

Postby Kambiz » May 12th, 2005, 9:37 am

Hi,

I'm sorry for being so late. I forgot to come back to this topic. :oops:

By modifications you did in PrintPreview, actually you set the condition always true, because if and else parts of the condition are identical except that you didn't consider custom paper sizes for the else part.

Now the question is: when a form is selected, shall we also set the paper size field for NT? According to Microsoft documentations, printer drivers on Win9x ignore FormName field, so we should set paper size field in Win9x. Seems there are also some printer drivers on NT, which ignore form name field too. :roll: Which OS are you using?

By the way, in PrintPreview setting the FormName property updates the PaperType property value and vice versa. Therefore, the modifications you suggested for the demo program are not necessary at all.

Cheers
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest