Einzelnen Beitrag anzeigen

Benutzerbild von dataspider
dataspider

Registriert seit: 9. Nov 2003
Ort: 04539 Groitzsch
1.350 Beiträge
 
Delphi 11 Alexandria
 
#1

PrintDialog.Execute wird nicht ausgeführt

  Alt 12. Feb 2018, 19:51
Ich habe eine Funktion zum Aufruf von TPrintDialog

Delphi-Quellcode:
function PrintDialog(var AFromPage, AToPage: Integer): Boolean;
Var
  APrintDialog: TPrintDialog;
begin
  APrintDialog := TPrintDialog.Create(Application);
  try
    APrintDialog.Options := [poPageNums];
    APrintDialog.PrintRange := prPageNums;
    APrintDialog.FromPage := AFromPage;
    APrintDialog.MaxPage := AToPage;
    APrintDialog.ToPage := AToPage;
    Result := APrintDialog.Execute;
    AFromPage := APrintDialog.FromPage;
    AToPage := APrintDialog.ToPage;
  finally
    APrintDialog.Free;
  end;
end;
Die rufe ich hier auf:

Delphi-Quellcode:
procedure TImageViewer.Print(AShowDialog: Boolean = True);
var
  RR: TRect;
  ABitMap: TBitmap;
  AFileName: string;
  AFromPage: Integer;
  AToPage: Integer;
  APrintPage: Integer;
  AFileStream: TMemoryStream;
begin
  AFromPage := 1;
  AToPage := PageCount;
  if not PrintDialog(AFromPage, AToPage) then
    Exit;
  ABitMap := TBitmap.Create;
  AFileStream := TMemoryStream.Create;
  try
    Printer.BeginDoc;
    try
      for APrintPage := AFromPage to AToPage do
      begin
        AFileStream.Clear;
        if Provider.DocProviderMode = dpmFile then
        begin
          AFileName := FileNames[APrintPage -1];
          AFileStream.LoadFromFile(AFileName)
        end
        else
          Provider.AssignFileFromDataSet(AFileStream);
        AssignImage(ABitMap, AFileStream, IsTiff(Provider.FileExtension));
        RR := Rect(0, 0, ABitMap.Width, ABitMap.Height);
        PrintBitmapEx(ABitMap);
        if APrintPage < AToPage then
          Printer.NewPage;
      end;
    finally
      Printer.EndDoc;
    end;
  finally
    ABitMap.Free;
    AFileStream.Free;
  end;
end;
Nur hier passiert einfach nichts. Der Dialog wird nicht angezeigt.
Wenn ich die Funktion an anderer Stelle aufrufe, ist alles schick.
Ich verzweifle langsam. Im Debugger springt er auch in die Routine in Vcl.Dialogs.

Was kann man falsch machen oder wo könnte man bei der Ursachensuche ansetzen?

Frank
Frank Reim
  Mit Zitat antworten Zitat