RB 16.03 - crash on printing
Hi,
I read in the newsgroup that there was a problem with old reports that
resulted in AV in ReportBuilder. We are experiencing the problem with
reports made with RB 16.03 while printing the invoices. The thing is
quite problematic since in our country we implemented fiscal cashiers
before new year 2016 and we have to count copies of invoice printed.
Since this AV is silent, many times occured that user pressed button
Print few times, counter counted up to 15 copies but no invoice has
been printed.
Due to restrictions of our IRS, we had to:
- prevent changing the copy count on RB print dialog
- prevent to open the printer properties dialog on RB Print dialog
To do this I had to inherit RB print dialog as per RBWiki and this code
was added into the datamodule where printing occurs:
procedure TdmRacunPaciPrint.ReportPrintDialogCreate(Sender: TObject);
begin
ppRepRacun.PrinterSetup.Copies := 1;
if ppRepRacun.PrintDialog is TppAxPrintDlg then
with TppAxPrintDlg(ppRepRacun.PrintDialog) do
begin
CopiesEnabled := False;
PrinterPropertyEnabled := False;
end;
end;
//----------------------------------------------------------------------
--------
procedure TdmRacunPaciPrint.ReportPrintDialogClose(Sender: TObject);
begin
FPrintDialogOk := ppRepRacun.PrintDialog.ModalResult = mrOk;
if Assigned(ppRepRacun.PreviewForm) then
ppRepRacun.PreviewForm.Close;
end;
//----------------------------------------------------------------------
--------
procedure TdmRacunPaciPrint.ReportAfterPrint(Sender: TObject);
begin
if Assigned(ppRepRacun.PreviewForm) then
ppRepRacun.PreviewForm.Close;
end;
I had luck so once this AV happened while I was debugging printing and
really, the AV happened on ppRepRacun.Print. This is the sample code of
printing:
===========================================================
if not FileExists(sReport) then
begin
MsgBox(Format('The report %s could not be found!',
[ExtractFileName(sReport)]), rstrMsgTitleNapaka, mtError, [mbOk]);
Exit;
end;
RepRacun := TppReport.Create(self);
try
with RepRacun do
begin
Template.FileName := sReport;
Template.LoadFromFile;
DeviceType := cRBOutputScreen;
AllowPrintToFile := True;
TppEmail(Email).SMTP.OnEmailError := ppRepRacunEmailError;
EmailSettings.Enabled := True;
EmailSettings.ReportFormat := 'PDF';
EmailSettings.Subject := PrinterSetup.DocumentName;
if cdsPacient.Active then
if not cdsPacient.IsEmpty then
begin
EmailSettings.Recipients.Clear;
if Trim(cdsPacientEmailOsebni.asString) <> '' then
begin
sTemp := Trim(cdsPacientEmailOsebni.asString);
sTemp := ReplaceStr(sTemp, ' ', '');
sTemp := ReplaceStr(sTemp, ';', '; ');
sTemp := ReplaceStr(sTemp, ',', '; ');
EmailSettings.Recipients.Delimiter := ';';
EmailSettings.Recipients.DelimitedText := sTemp;
end;
if Trim(cdsPacientEmailSluzba.asString) <> '' then
begin
sTemp := Trim(cdsPacientEmailSluzba.asString);
sTemp := ReplaceStr(sTemp, ' ', '');
sTemp := ReplaceStr(sTemp, ';', '; ');
sTemp := ReplaceStr(sTemp, ',', '; ');
EmailSettings.Recipients.Delimiter := ';';
EmailSettings.Recipients.DelimitedText := sTemp;
end;
if Trim(cdsPacientEmail3.asString) <> '' then
begin
sTemp := Trim(cdsPacientEmail3.asString);
sTemp := ReplaceStr(sTemp, ' ', '');
sTemp := ReplaceStr(sTemp, ';', '; ');
sTemp := ReplaceStr(sTemp, ',', '; ');
EmailSettings.Recipients.Delimiter := ';';
EmailSettings.Recipients.DelimitedText := sTemp;
end;
end;
EmailSettings.FileName := Format(rstrEmailDatRacunPdf,
[cdsRacunMasterStevRacuna.AsString]);
PDFSettings.ScaleImages := False;
TextFileName := glSkupno.ProgramData.MapaTemp +
Format(rstrEmailDatRacunPdf, [cdsRacunMasterStevRacuna.AsString]);
PreviewFormSettings.WindowState := wsMaximized;
PreviewFormSettings.ZoomSetting := zs100percent;
SavePrinterSetup := True;
if not bPOS then
begin
PrinterSetup.PrinterName := glSkupno.PrinterSetting.PrinterName;
PrinterSetup.BinName := glSkupno.PrinterSetting.BinName;
end
else
begin
PrinterSetup.PrinterName := glPOSData.PrinterName;
PrinterSetup.PaperWidth := glPOSData.SirinaPapirja;
PrinterSetup.MarginLeft := glPOSData.MarginaLevo;
PrinterSetup.MarginRight := glPOSData.MarginaDesno;
end;
case ATipIzpisa of
trPoloznica, trObveznoPoloznica :
begin
sVrednost :=
dmSkupno.IniNastavitevDobi('POLOZNICA','POLOZNICASP');
if not TryStrToInt(sVrednost, iTemp) then
iTemp := 0;
PrinterSetup.MarginBottom := PrinterSetup.MarginBottom +
iTemp /10;
sVrednost :=
dmSkupno.IniNastavitevDobi('POLOZNICA','POLOZNICALEVO');
if not TryStrToInt(sVrednost, iTemp) then
iTemp := 0;
PrinterSetup.MarginLeft := PrinterSetup.MarginLeft + iTemp
/10;
end;
end;
LanguageID := cRBLanguageSLO;
ThumbnailSettings.Visible := False;
if APokaziDlg and not bPOS then
ShowPrintDialog := True
else
ShowPrintDialog := False;
//http://www.digital-metaphors.com:8080/Plugins/Dialogs/How_To...Create_a_Custom_Print_Dialog
//ppPDlg.pas
//Obvezna blokada tiskanja vec kot ene kopije
PrinterSetup.Copies := 1;
OnPrintDialogCreate := ReportPrintDialogCreate;
OnPrintDialogClose := ReportPrintDialogClose;
AfterPrint := ReportAfterPrint;
Print;
if not bPOS then
begin
glSkupno.PrinterSetting.PrinterName := PrinterSetup.PrinterName;
glSkupno.PrinterSetting.BinName := PrinterSetup.BinName;
end;
Result := FPrintDialogOk;
end;
finally
RepRacun.Free;
end;
===========================================================
And finally, here is the report made by MadExcept from a test machine
that happened today in my company:
===========================================================
date/time : 2016-02-11, 11:45:17, 810ms
computer name : DENT-TP1
user name : tomazk
registered owner : demo / Hewlett-Packard Company
operating system : Windows 7 x64 Service Pack 1 build 7601
system language : Slovenian
system up time : 3 hours 48 minutes
program up time : 11 minutes 43 seconds
processors : 4x Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
physical memory : 2467/8118 MB (free/total)
free disk space : (C:) 483,45 GB
display mode : 1920x1080, 32 bit
process id : $2b8c
allocated memory : 255,98 MB
largest free block : 403,93 MB
executable : AXPRO.EXE
exec. date/time : 2016-02-05 15:58
version : 3.20.1.1027
compiled with : Delphi XE
madExcept version : 4.0.12
contact name : Goran
contact email : brumen.goran@audax.si
callstack crc : $86752e84, $7dee63cf, $7dee63cf
exception number : 5
exception class : EAccessViolation
exception message : Access violation at address 022A9513 in module
'AXPRO.EXE'. Read of address 000002B8.
main thread ($2884):
022a9513 +01b AXPRO.EXE UdmRacunPaciPrint 706 +1
TdmRacunPaciPrint.ReportPrintDialogClose
01218681 +015 AXPRO.EXE ppProd
TppProducer.DoOnPrintDialogClose
01217419 +12d AXPRO.EXE ppProd
TppProducer.PrintToPrinter
01216fcc +054 AXPRO.EXE ppProd
TppProducer.PrintWithSameParameters
0104cdee +12e AXPRO.EXE ppViewr TppViewer.Print
0113d4fe +04a AXPRO.EXE ppPreview
TppCustomPreview.Print
0113d5b5 +079 AXPRO.EXE ppPreview
TppCustomPreview.PerformPreviewAction
0113ff54 +044 AXPRO.EXE ppPreview
TppPreview.ehToolbutton_Click
010b57dc +0a8 AXPRO.EXE ppTB2Item
TppTBCustomItem.Click
010b56bb +0b3 AXPRO.EXE ppTB2Item
TppTBCustomItem.ClickWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
75217895 +00a USER32.dll DispatchMessageW
0064a2ff +0f3 AXPRO.EXE Forms
TApplication.ProcessMessage
0064a342 +00a AXPRO.EXE Forms
TApplication.HandleMessage
00645ca1 +1a1 AXPRO.EXE Forms
TCustomForm.ShowModal
0121eccf +01f AXPRO.EXE ppForms TppForm.ShowModal
01217289 +089 AXPRO.EXE ppProd
TppProducer.PrintToScreen
01216f47 +05f AXPRO.EXE ppProd TppProducer.Print
0114b786 +01e AXPRO.EXE ppReport TppReport.Print
022b4651 +7b5 AXPRO.EXE UdmRacunPaciPrint 2907 +118
TdmRacunPaciPrint.RacunTiskaj
022b6b1e +1c2 AXPRO.EXE UdmRacunPaciPrint 3438 +36
TdmRacunPaciPrint.RacunPacientTiskaj
022e5f0a +356 AXPRO.EXE UfrmRacunPacient 1973 +64
TfrmRacunPacient.NatisniRacun
022e19a6 +046 AXPRO.EXE UfrmRacunPacient 826 +20
TfrmRacunPacient.bbtnNatisniClick
0058cae7 +06f AXPRO.EXE Controls TControl.Click
005c3b1a +01e AXPRO.EXE StdCtrls
TCustomButton.Click
00973624 +0a0 AXPRO.EXE cxButtons 1655 +8
TcxCustomButton.Click
005c4608 +010 AXPRO.EXE StdCtrls
TCustomButton.CNCommand
00973fff +033 AXPRO.EXE cxButtons 1948 +2
TcxCustomButton.CNCommand
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
005c37e4 +06c AXPRO.EXE StdCtrls
TButtonControl.WndProc
00973f53 +093 AXPRO.EXE cxButtons 1929 +11
TcxCustomButton.WndProc
0058c1a0 +024 AXPRO.EXE Controls TControl.Perform
00590f93 +023 AXPRO.EXE Controls DoControlMsg
005919ef +00b AXPRO.EXE Controls
TWinControl.WMCommand
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
005904e0 +02c AXPRO.EXE Controls
TWinControl.MainWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
77430137 +02b ntdll.dll
KiUserCallbackDispatcher
752196d0 +047 USER32.dll SendMessageW
75220d58 +016 USER32.dll CallWindowProcW
00590f40 +0d8 AXPRO.EXE Controls
TWinControl.DefaultHandler
009736fb +023 AXPRO.EXE cxButtons 1672 +2
TcxCustomButton.DefaultHandler
0058cf38 +010 AXPRO.EXE Controls
TControl.WMLButtonUp
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
005c37e4 +06c AXPRO.EXE StdCtrls
TButtonControl.WndProc
00973f53 +093 AXPRO.EXE cxButtons 1929 +11
TcxCustomButton.WndProc
005904e0 +02c AXPRO.EXE Controls
TWinControl.MainWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
75217895 +00a USER32.dll DispatchMessageW
0064a2ff +0f3 AXPRO.EXE Forms
TApplication.ProcessMessage
0064a342 +00a AXPRO.EXE Forms
TApplication.HandleMessage
00645ca1 +1a1 AXPRO.EXE Forms
TCustomForm.ShowModal
022f554d +275 AXPRO.EXE UfrmRacunPacient 5384 +43 RacunZaPacienta
026b4e0b +26f AXPRO.EXE UFKartoteka 1651 +56
TFKartoteka.UrediZapis
0289bb50 +088 AXPRO.EXE UfwmKartotekaStom 200 +1
TfwmKartotekaStom.UrediZapis
026b123c +2dc AXPRO.EXE UFKartoteka 838 +19
TFKartoteka.dbgKartotekaTVMouseDown
0058cb3c +02c AXPRO.EXE Controls
TControl.MouseDown
007236ed +191 AXPRO.EXE cxControls 6172 +28
TcxControl.MouseDown
00b049aa +02a AXPRO.EXE cxGridCustomView 5162 +2
TcxGridSite.MouseDown
0058cbd4 +08c AXPRO.EXE Controls
TControl.DoMouseDown
0058cc93 +047 AXPRO.EXE Controls
TControl.WMLButtonDblClk
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
0072297a +146 AXPRO.EXE cxControls 5818 +19
TcxControl.WndProc
00b04dac +034 AXPRO.EXE cxGridCustomView 5265 +3
TcxGridSite.WndProc
005904e0 +02c AXPRO.EXE Controls
TWinControl.MainWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
75217895 +00a USER32.dll DispatchMessageW
0064a2ff +0f3 AXPRO.EXE Forms
TApplication.ProcessMessage
0064a342 +00a AXPRO.EXE Forms
TApplication.HandleMessage
0064a66d +0c9 AXPRO.EXE Forms TApplication.Run
02a53791 +041 AXPRO.EXE AxPro 924 +12 initialization
754a3388 +010 kernel32.dll
BaseThreadInitThunk
thread $279c:
75217c28 +45 USER32.dll GetMessageA
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
71296c8b +00 winmm.dll
thread $2434:
774401f6 +0e ntdll.dll NtWaitForMultipleObjects
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $19c4:
7743f96a +0e ntdll.dll NtWaitForSingleObject
76d415b9 +92 KERNELBASE.dll WaitForSingleObjectEx
754a118f +3e kernel32.dll WaitForSingleObjectEx
754a1143 +0d kernel32.dll WaitForSingleObject
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
71304c95 +00 winspool.drv
thread $2bc0:
774401f6 +0e ntdll.dll NtWaitForMultipleObjects
76d41705 +fa KERNELBASE.dll WaitForMultipleObjectsEx
754a1a07 +89 kernel32.dll WaitForMultipleObjectsEx
754a41fb +13 kernel32.dll WaitForMultipleObjects
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792caa9e +00 mscorwks.dll
thread $29c0:
774401f6 +0e ntdll.dll NtWaitForMultipleObjects
76d41705 +fa KERNELBASE.dll WaitForMultipleObjectsEx
754a1a07 +89 kernel32.dll WaitForMultipleObjectsEx
754a41fb +13 kernel32.dll WaitForMultipleObjects
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792e20b4 +00 mscorwks.dll
thread $2be0:
7743f9f2 +0e ntdll.dll NtRemoveIoCompletion
76d376ff +23 KERNELBASE.dll GetQueuedCompletionStatus
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792e20b4 +00 mscorwks.dll
thread $29a4:
7743fe2a +0e ntdll.dll NtDelayExecution
76d43d37 +5f KERNELBASE.dll SleepEx
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792e9a13 +00 mscorwks.dll
thread $2554:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $29f8:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2f40:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2560:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2b98:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $28fc:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2fdc:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $1f80:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $20c8 (TppPageRequestThread):
774401f6 +0e ntdll.dll
NtWaitForMultipleObjects
76d41705 +fa KERNELBASE.dll
WaitForMultipleObjectsEx
754a1a07 +89 kernel32.dll
WaitForMultipleObjectsEx
004d9d56 +56 AXPRO.EXE SyncObjs
THandleObject.WaitFor
0103c0b7 +33 AXPRO.EXE ppThreadedPageCache
TppPageRequestThread.Execute
0047e1ab +2b AXPRO.EXE madExcept
HookedTThreadExecute
004d230e +42 AXPRO.EXE Classes ThreadProc
00408314 +28 AXPRO.EXE System 71 +0 ThreadWrapper
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll
BaseThreadInitThunk
0103bf19 +19 AXPRO.EXE ppThreadedPageCache
TppPageRequestThread.Create
thread $2fa0:
7743fe2a +0e ntdll.dll NtDelayExecution
76d43d37 +5f KERNELBASE.dll SleepEx
76d44608 +0a KERNELBASE.dll Sleep
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
756cda6e +00 ole32.dll
thread $1874:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
===========================================================
Is there any solution to the problem?
Best regards,
Goran Brumen
Audax d.o.o.
I read in the newsgroup that there was a problem with old reports that
resulted in AV in ReportBuilder. We are experiencing the problem with
reports made with RB 16.03 while printing the invoices. The thing is
quite problematic since in our country we implemented fiscal cashiers
before new year 2016 and we have to count copies of invoice printed.
Since this AV is silent, many times occured that user pressed button
Print few times, counter counted up to 15 copies but no invoice has
been printed.
Due to restrictions of our IRS, we had to:
- prevent changing the copy count on RB print dialog
- prevent to open the printer properties dialog on RB Print dialog
To do this I had to inherit RB print dialog as per RBWiki and this code
was added into the datamodule where printing occurs:
procedure TdmRacunPaciPrint.ReportPrintDialogCreate(Sender: TObject);
begin
ppRepRacun.PrinterSetup.Copies := 1;
if ppRepRacun.PrintDialog is TppAxPrintDlg then
with TppAxPrintDlg(ppRepRacun.PrintDialog) do
begin
CopiesEnabled := False;
PrinterPropertyEnabled := False;
end;
end;
//----------------------------------------------------------------------
--------
procedure TdmRacunPaciPrint.ReportPrintDialogClose(Sender: TObject);
begin
FPrintDialogOk := ppRepRacun.PrintDialog.ModalResult = mrOk;
if Assigned(ppRepRacun.PreviewForm) then
ppRepRacun.PreviewForm.Close;
end;
//----------------------------------------------------------------------
--------
procedure TdmRacunPaciPrint.ReportAfterPrint(Sender: TObject);
begin
if Assigned(ppRepRacun.PreviewForm) then
ppRepRacun.PreviewForm.Close;
end;
I had luck so once this AV happened while I was debugging printing and
really, the AV happened on ppRepRacun.Print. This is the sample code of
printing:
===========================================================
if not FileExists(sReport) then
begin
MsgBox(Format('The report %s could not be found!',
[ExtractFileName(sReport)]), rstrMsgTitleNapaka, mtError, [mbOk]);
Exit;
end;
RepRacun := TppReport.Create(self);
try
with RepRacun do
begin
Template.FileName := sReport;
Template.LoadFromFile;
DeviceType := cRBOutputScreen;
AllowPrintToFile := True;
TppEmail(Email).SMTP.OnEmailError := ppRepRacunEmailError;
EmailSettings.Enabled := True;
EmailSettings.ReportFormat := 'PDF';
EmailSettings.Subject := PrinterSetup.DocumentName;
if cdsPacient.Active then
if not cdsPacient.IsEmpty then
begin
EmailSettings.Recipients.Clear;
if Trim(cdsPacientEmailOsebni.asString) <> '' then
begin
sTemp := Trim(cdsPacientEmailOsebni.asString);
sTemp := ReplaceStr(sTemp, ' ', '');
sTemp := ReplaceStr(sTemp, ';', '; ');
sTemp := ReplaceStr(sTemp, ',', '; ');
EmailSettings.Recipients.Delimiter := ';';
EmailSettings.Recipients.DelimitedText := sTemp;
end;
if Trim(cdsPacientEmailSluzba.asString) <> '' then
begin
sTemp := Trim(cdsPacientEmailSluzba.asString);
sTemp := ReplaceStr(sTemp, ' ', '');
sTemp := ReplaceStr(sTemp, ';', '; ');
sTemp := ReplaceStr(sTemp, ',', '; ');
EmailSettings.Recipients.Delimiter := ';';
EmailSettings.Recipients.DelimitedText := sTemp;
end;
if Trim(cdsPacientEmail3.asString) <> '' then
begin
sTemp := Trim(cdsPacientEmail3.asString);
sTemp := ReplaceStr(sTemp, ' ', '');
sTemp := ReplaceStr(sTemp, ';', '; ');
sTemp := ReplaceStr(sTemp, ',', '; ');
EmailSettings.Recipients.Delimiter := ';';
EmailSettings.Recipients.DelimitedText := sTemp;
end;
end;
EmailSettings.FileName := Format(rstrEmailDatRacunPdf,
[cdsRacunMasterStevRacuna.AsString]);
PDFSettings.ScaleImages := False;
TextFileName := glSkupno.ProgramData.MapaTemp +
Format(rstrEmailDatRacunPdf, [cdsRacunMasterStevRacuna.AsString]);
PreviewFormSettings.WindowState := wsMaximized;
PreviewFormSettings.ZoomSetting := zs100percent;
SavePrinterSetup := True;
if not bPOS then
begin
PrinterSetup.PrinterName := glSkupno.PrinterSetting.PrinterName;
PrinterSetup.BinName := glSkupno.PrinterSetting.BinName;
end
else
begin
PrinterSetup.PrinterName := glPOSData.PrinterName;
PrinterSetup.PaperWidth := glPOSData.SirinaPapirja;
PrinterSetup.MarginLeft := glPOSData.MarginaLevo;
PrinterSetup.MarginRight := glPOSData.MarginaDesno;
end;
case ATipIzpisa of
trPoloznica, trObveznoPoloznica :
begin
sVrednost :=
dmSkupno.IniNastavitevDobi('POLOZNICA','POLOZNICASP');
if not TryStrToInt(sVrednost, iTemp) then
iTemp := 0;
PrinterSetup.MarginBottom := PrinterSetup.MarginBottom +
iTemp /10;
sVrednost :=
dmSkupno.IniNastavitevDobi('POLOZNICA','POLOZNICALEVO');
if not TryStrToInt(sVrednost, iTemp) then
iTemp := 0;
PrinterSetup.MarginLeft := PrinterSetup.MarginLeft + iTemp
/10;
end;
end;
LanguageID := cRBLanguageSLO;
ThumbnailSettings.Visible := False;
if APokaziDlg and not bPOS then
ShowPrintDialog := True
else
ShowPrintDialog := False;
//http://www.digital-metaphors.com:8080/Plugins/Dialogs/How_To...Create_a_Custom_Print_Dialog
//ppPDlg.pas
//Obvezna blokada tiskanja vec kot ene kopije
PrinterSetup.Copies := 1;
OnPrintDialogCreate := ReportPrintDialogCreate;
OnPrintDialogClose := ReportPrintDialogClose;
AfterPrint := ReportAfterPrint;
Print;
if not bPOS then
begin
glSkupno.PrinterSetting.PrinterName := PrinterSetup.PrinterName;
glSkupno.PrinterSetting.BinName := PrinterSetup.BinName;
end;
Result := FPrintDialogOk;
end;
finally
RepRacun.Free;
end;
===========================================================
And finally, here is the report made by MadExcept from a test machine
that happened today in my company:
===========================================================
date/time : 2016-02-11, 11:45:17, 810ms
computer name : DENT-TP1
user name : tomazk
registered owner : demo / Hewlett-Packard Company
operating system : Windows 7 x64 Service Pack 1 build 7601
system language : Slovenian
system up time : 3 hours 48 minutes
program up time : 11 minutes 43 seconds
processors : 4x Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
physical memory : 2467/8118 MB (free/total)
free disk space : (C:) 483,45 GB
display mode : 1920x1080, 32 bit
process id : $2b8c
allocated memory : 255,98 MB
largest free block : 403,93 MB
executable : AXPRO.EXE
exec. date/time : 2016-02-05 15:58
version : 3.20.1.1027
compiled with : Delphi XE
madExcept version : 4.0.12
contact name : Goran
contact email : brumen.goran@audax.si
callstack crc : $86752e84, $7dee63cf, $7dee63cf
exception number : 5
exception class : EAccessViolation
exception message : Access violation at address 022A9513 in module
'AXPRO.EXE'. Read of address 000002B8.
main thread ($2884):
022a9513 +01b AXPRO.EXE UdmRacunPaciPrint 706 +1
TdmRacunPaciPrint.ReportPrintDialogClose
01218681 +015 AXPRO.EXE ppProd
TppProducer.DoOnPrintDialogClose
01217419 +12d AXPRO.EXE ppProd
TppProducer.PrintToPrinter
01216fcc +054 AXPRO.EXE ppProd
TppProducer.PrintWithSameParameters
0104cdee +12e AXPRO.EXE ppViewr TppViewer.Print
0113d4fe +04a AXPRO.EXE ppPreview
TppCustomPreview.Print
0113d5b5 +079 AXPRO.EXE ppPreview
TppCustomPreview.PerformPreviewAction
0113ff54 +044 AXPRO.EXE ppPreview
TppPreview.ehToolbutton_Click
010b57dc +0a8 AXPRO.EXE ppTB2Item
TppTBCustomItem.Click
010b56bb +0b3 AXPRO.EXE ppTB2Item
TppTBCustomItem.ClickWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
75217895 +00a USER32.dll DispatchMessageW
0064a2ff +0f3 AXPRO.EXE Forms
TApplication.ProcessMessage
0064a342 +00a AXPRO.EXE Forms
TApplication.HandleMessage
00645ca1 +1a1 AXPRO.EXE Forms
TCustomForm.ShowModal
0121eccf +01f AXPRO.EXE ppForms TppForm.ShowModal
01217289 +089 AXPRO.EXE ppProd
TppProducer.PrintToScreen
01216f47 +05f AXPRO.EXE ppProd TppProducer.Print
0114b786 +01e AXPRO.EXE ppReport TppReport.Print
022b4651 +7b5 AXPRO.EXE UdmRacunPaciPrint 2907 +118
TdmRacunPaciPrint.RacunTiskaj
022b6b1e +1c2 AXPRO.EXE UdmRacunPaciPrint 3438 +36
TdmRacunPaciPrint.RacunPacientTiskaj
022e5f0a +356 AXPRO.EXE UfrmRacunPacient 1973 +64
TfrmRacunPacient.NatisniRacun
022e19a6 +046 AXPRO.EXE UfrmRacunPacient 826 +20
TfrmRacunPacient.bbtnNatisniClick
0058cae7 +06f AXPRO.EXE Controls TControl.Click
005c3b1a +01e AXPRO.EXE StdCtrls
TCustomButton.Click
00973624 +0a0 AXPRO.EXE cxButtons 1655 +8
TcxCustomButton.Click
005c4608 +010 AXPRO.EXE StdCtrls
TCustomButton.CNCommand
00973fff +033 AXPRO.EXE cxButtons 1948 +2
TcxCustomButton.CNCommand
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
005c37e4 +06c AXPRO.EXE StdCtrls
TButtonControl.WndProc
00973f53 +093 AXPRO.EXE cxButtons 1929 +11
TcxCustomButton.WndProc
0058c1a0 +024 AXPRO.EXE Controls TControl.Perform
00590f93 +023 AXPRO.EXE Controls DoControlMsg
005919ef +00b AXPRO.EXE Controls
TWinControl.WMCommand
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
005904e0 +02c AXPRO.EXE Controls
TWinControl.MainWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
77430137 +02b ntdll.dll
KiUserCallbackDispatcher
752196d0 +047 USER32.dll SendMessageW
75220d58 +016 USER32.dll CallWindowProcW
00590f40 +0d8 AXPRO.EXE Controls
TWinControl.DefaultHandler
009736fb +023 AXPRO.EXE cxButtons 1672 +2
TcxCustomButton.DefaultHandler
0058cf38 +010 AXPRO.EXE Controls
TControl.WMLButtonUp
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
005c37e4 +06c AXPRO.EXE StdCtrls
TButtonControl.WndProc
00973f53 +093 AXPRO.EXE cxButtons 1929 +11
TcxCustomButton.WndProc
005904e0 +02c AXPRO.EXE Controls
TWinControl.MainWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
75217895 +00a USER32.dll DispatchMessageW
0064a2ff +0f3 AXPRO.EXE Forms
TApplication.ProcessMessage
0064a342 +00a AXPRO.EXE Forms
TApplication.HandleMessage
00645ca1 +1a1 AXPRO.EXE Forms
TCustomForm.ShowModal
022f554d +275 AXPRO.EXE UfrmRacunPacient 5384 +43 RacunZaPacienta
026b4e0b +26f AXPRO.EXE UFKartoteka 1651 +56
TFKartoteka.UrediZapis
0289bb50 +088 AXPRO.EXE UfwmKartotekaStom 200 +1
TfwmKartotekaStom.UrediZapis
026b123c +2dc AXPRO.EXE UFKartoteka 838 +19
TFKartoteka.dbgKartotekaTVMouseDown
0058cb3c +02c AXPRO.EXE Controls
TControl.MouseDown
007236ed +191 AXPRO.EXE cxControls 6172 +28
TcxControl.MouseDown
00b049aa +02a AXPRO.EXE cxGridCustomView 5162 +2
TcxGridSite.MouseDown
0058cbd4 +08c AXPRO.EXE Controls
TControl.DoMouseDown
0058cc93 +047 AXPRO.EXE Controls
TControl.WMLButtonDblClk
0058c57c +2d4 AXPRO.EXE Controls TControl.WndProc
00590e40 +568 AXPRO.EXE Controls
TWinControl.WndProc
0072297a +146 AXPRO.EXE cxControls 5818 +19
TcxControl.WndProc
00b04dac +034 AXPRO.EXE cxGridCustomView 5265 +3
TcxGridSite.WndProc
005904e0 +02c AXPRO.EXE Controls
TWinControl.MainWndProc
004d509c +014 AXPRO.EXE Classes StdWndProc
75217895 +00a USER32.dll DispatchMessageW
0064a2ff +0f3 AXPRO.EXE Forms
TApplication.ProcessMessage
0064a342 +00a AXPRO.EXE Forms
TApplication.HandleMessage
0064a66d +0c9 AXPRO.EXE Forms TApplication.Run
02a53791 +041 AXPRO.EXE AxPro 924 +12 initialization
754a3388 +010 kernel32.dll
BaseThreadInitThunk
thread $279c:
75217c28 +45 USER32.dll GetMessageA
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
71296c8b +00 winmm.dll
thread $2434:
774401f6 +0e ntdll.dll NtWaitForMultipleObjects
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $19c4:
7743f96a +0e ntdll.dll NtWaitForSingleObject
76d415b9 +92 KERNELBASE.dll WaitForSingleObjectEx
754a118f +3e kernel32.dll WaitForSingleObjectEx
754a1143 +0d kernel32.dll WaitForSingleObject
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
71304c95 +00 winspool.drv
thread $2bc0:
774401f6 +0e ntdll.dll NtWaitForMultipleObjects
76d41705 +fa KERNELBASE.dll WaitForMultipleObjectsEx
754a1a07 +89 kernel32.dll WaitForMultipleObjectsEx
754a41fb +13 kernel32.dll WaitForMultipleObjects
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792caa9e +00 mscorwks.dll
thread $29c0:
774401f6 +0e ntdll.dll NtWaitForMultipleObjects
76d41705 +fa KERNELBASE.dll WaitForMultipleObjectsEx
754a1a07 +89 kernel32.dll WaitForMultipleObjectsEx
754a41fb +13 kernel32.dll WaitForMultipleObjects
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792e20b4 +00 mscorwks.dll
thread $2be0:
7743f9f2 +0e ntdll.dll NtRemoveIoCompletion
76d376ff +23 KERNELBASE.dll GetQueuedCompletionStatus
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792e20b4 +00 mscorwks.dll
thread $29a4:
7743fe2a +0e ntdll.dll NtDelayExecution
76d43d37 +5f KERNELBASE.dll SleepEx
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
792e9a13 +00 mscorwks.dll
thread $2554:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $29f8:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2f40:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2560:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2b98:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $28fc:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $2fdc:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $1f80:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
thread $20c8 (TppPageRequestThread):
774401f6 +0e ntdll.dll
NtWaitForMultipleObjects
76d41705 +fa KERNELBASE.dll
WaitForMultipleObjectsEx
754a1a07 +89 kernel32.dll
WaitForMultipleObjectsEx
004d9d56 +56 AXPRO.EXE SyncObjs
THandleObject.WaitFor
0103c0b7 +33 AXPRO.EXE ppThreadedPageCache
TppPageRequestThread.Execute
0047e1ab +2b AXPRO.EXE madExcept
HookedTThreadExecute
004d230e +42 AXPRO.EXE Classes ThreadProc
00408314 +28 AXPRO.EXE System 71 +0 ThreadWrapper
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll
BaseThreadInitThunk
0103bf19 +19 AXPRO.EXE ppThreadedPageCache
TppPageRequestThread.Create
thread $2fa0:
7743fe2a +0e ntdll.dll NtDelayExecution
76d43d37 +5f KERNELBASE.dll SleepEx
76d44608 +0a KERNELBASE.dll Sleep
0047e08d +0d AXPRO.EXE madExcept CallThreadProcSafe
0047e0f7 +37 AXPRO.EXE madExcept ThreadExceptFrame
754a3388 +10 kernel32.dll BaseThreadInitThunk
756cda6e +00 ole32.dll
thread $1874:
77441fdf +0b ntdll.dll NtWaitForWorkViaWorkerFactory
754a3388 +10 kernel32.dll BaseThreadInitThunk
===========================================================
Is there any solution to the problem?
Best regards,
Goran Brumen
Audax d.o.o.
This discussion has been closed.
Comments
According the call stack you posted, the exception occurs in
TdmRacunPaciPrint.ReportPrintDialogClose
Rather than calling PreviewForm Close, try setting ModalResult to mrOk or
mrCancel, this is safer.
Also, note Report AfterPrint can fire multiple times. For example after
print to printer/file and again when preview form is closed (i.e. after
print to screen.
Try this...
procedure TForm1.ppReport1AfterPrint(Sender: TObject);
begin
// close preview form after print to printer/file
if (ppReport1.DeviceType <> dtScreen) then
if (ppReport1.PreviewForm <> nil) then
ppReport1.PreviewForm.ModalResult := mrCancel;
end;
procedure TForm1.ppReport1PrintDialogClose(Sender: TObject);
begin
// close preview form, when print dialog cancelled
if (ppReport1.PrintDialog.ModalResult = mrCancel) then
if (ppReport1.PreviewForm <> nil) then
ppReport1.PreviewForm.ModalResult := mrCancel;
end;
If the above does no help, please create a simple example project that I can
build and run in the debugger. Please use standard Delphi components and
RB. Copy data to TClientDataSets. Send in zip format - include only .dpr,
.pas, .dfm. Send to support@
Best regards,
-
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
thank You for the proposed solution, I shall try this and I hope it
will work!
Many thanks and best regards,
Goran