## Possible Bug in PrintPreview???

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

### Possible Bug in PrintPreview???

Hi @ all,

At first: Sorry for my english.

Now, i use the excellent "Print Preview Suite v4.62" to create a Preview Window for Images that should be printed. It works very well except one little thing.

In my Version, the user can adjust the Printer Properties ONLY in the Standard PrinterSetupDialog. UsePrinterOptions is set to True.

If i choose a new Paper Format (i.e. A5) and then it calls the CreatePages Procedure (the same way like the 'general demo'), BUT, i can not see the new format in the Preview. If i open again the Dialog and accept with OK (no other choice) than the change will be come. A little bit strange.

All other choices (i.e. Portrait or Landscape) i can see directly - no Problem with this.

Here is the Code for the PrinterSetupDialog - must be normal:

Code: Select all
procedure TMainForm.SetupButtonClick(Sender: TObject);begin  if PrintPreview.State = psReady then    if PrinterSetupDialog.Execute then CreatePages;end;

I hope anybody understand the problem and again...sorry for my english...

Thanks...EPS

EPS
Member

Posts: 3
Joined: September 1st, 2005, 6:45 pm
Location: Halle(Saale) - Germany

Hi,

When UsePrinterOptions property is True, the new printer settings are available after call to BeginDoc method. Therefore, if you use this settings to calculate page bounds before calling to BeginDoc, the result would be wrong. I gess you did that.

To solve the problem, either you have to use printer settings after calling BeginDoc method or set UsePrinterOptions to False and call GetPrinterOptions method manually before using the printer settings.

Cheers
Kambiz

Kambiz

Posts: 2429
Joined: March 7th, 2003, 7:10 pm

No, that's not the reason...

I think you don't understand me correctly. I try again to explain (maybe with pictures it is easyer)...

Ok, in my program i do the following:

1. After the start i see in the preview the standard Paper Format (A4)

2. I press the button "PrinterSetup" and get the Dialog. In the Dialog i choose the Paper Format "Creditcard" and press OK.

3. The Preview looks like before.

4. I press again the "PrinterSetup" Button and now i press only OK.

5. Now, the Preview is correctly. (specialy the Thumbnailpreview)

And that's the Problem.

OK, another Test: If i call the SetupDialog and i choose only Portrait or Landscape, the Preview takes this effect immediately.

and again a Test: If i call the SetupDialog and i choose a new Paper Format together with a new Printer, the Preview takes this effect immediately.

...Result...my Function works correct, i can't explain why they do that, an the only reason can be that there is a little Bug in the Preview Routine (specialy the Routine for the Thumbnail Preview).

I hope u can help me, thank you very much...

EPS
Member

Posts: 3
Joined: September 1st, 2005, 6:45 pm
Location: Halle(Saale) - Germany

Before than posting my previous I checked the issue on my machine and I didn't see something wrong.

By the way, if you are relying on my sample codes, they have all that problem that I described. Because they don't use printer options in the way you are using.

Anyway, try this code:

Code: Select all
procedure TMainForm.SetupButtonClick(Sender: TObject); begin   if PrintPreview.State = psReady then     if PrinterSetupDialog.Execute then     begin      PrintPreview.GetPrinterOptions;      CreatePages;     end;end;
Kambiz

Kambiz

Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Ok, in this case i think the problem is my printer, i also tried out your idea, but it's also not working.

But...thank you very much for your help and for this first class function.

EPS
Member

Posts: 3
Joined: September 1st, 2005, 6:45 pm
Location: Halle(Saale) - Germany