WPCubed Product Support

EPrinter Error

Hi !

Recently I added the Labelprinting Feature to my application. Until that time I always get error if there is no printer defined in windows. The error message is called "Zur Zeit ist kein Standard-Drucker gewählt" or in englich "There is no default printer selected".

What can I do to prevent my application to crash if this occurs?

Maybe the Stacklist helps you:

Stack list, generated 02.05.06 22:18:45
[00437A21] Printers.RaiseError + $11
[0043895C] Printers.TPrinter.SetToDefaultPrinter + $80
[00404DE6] System.@HandleFinally + $2A
[004028D5] System.SysFreeMem + $1C1
[00402014] System.InternalFreeMem + $1C
[004029B1] System.ResizeInPlace + $C5
[00402C19] System.@ReallocMem + $D
[004028D5] System.SysFreeMem + $1C1
[00402BF1] System.@FreeMem + $5
[004045D4] System.TObject.FreeInstance + $C
[004049DE] System.@ClassDestroy + $2
[0041FF84] Classes.TList.Destroy + $18
[0040461C] System.TObject.Free + $8
[00583193] WPRTEDefs.TWPRTFDataBlock.Reformat + $903
[00584822] WPRTEDefs.TWPRTFStyleCollection.SetOptimizedSearch + $16
[0058342E] WPRTEDefs.TWPRTFDataBlock.Reformat + $B9E
[004028D5] System.SysFreeMem + $1C1
[00402014] System.InternalFreeMem + $1C
[004029B1] System.ResizeInPlace + $C5
[005F4A71] WPCTRMemo.TWPCustomRtfEdit.StartUpdate (Line 12422, "WPCTRMemo.pas" + 6) + $3
[005E7E84] WPCTRMemo.TWPCustomRtfEdit.DoBroadcastMsg (Line 4432, "WPCTRMemo.pas" + 42) + $C
[005A19E6] WPRTEPaint.TWPRTFEnginePaint.BroadcastEvent + $1E
[005A18AD] WPRTEPaint.TWPRTFEnginePaint.ReorderPaintPages + $EB5
[005A1ACB] WPRTEPaint.TWPRTFEnginePaint.BroadcastMsg + $DB
[004028D5] System.SysFreeMem + $1C1
[00402BF1] System.@FreeMem + $5
[004054E5] System.@LStrArrayClr + $21
[007085E1] LabelDrucken.TLabelDruckenForm.ColCountChange (Line 364, "LabelDrucken.pas" + 64) + $29
[004385E7] Printers.TPrinter.GetPrinterIndex + $B
[00437EB8] Printers.TPrinter.SetState + $98
[00404DE6] System.@HandleFinally + $2A
[004383CB] Printers.TPrinter.GetHandle + $7
[00707F68] LabelDrucken.TLabelDruckenForm.FormCreate (Line 272, "LabelDrucken.pas" + 16) + $5
[00404DE6] System.@HandleFinally + $2A
[0048A6C5] Forms.TCustomForm.DoCreate + $31
[0048A3A5] Forms.TCustomForm.AfterConstruction + $11
[004049EB] System.@AfterConstruction + $7
[0048A37C] Forms.TCustomForm.Create + $174
[00401599] System.AddBlockAfter + $9
[004020AF] System.FillerSizeBeforeGap + $6B
[00402364] System.MergeCommit + $68
[0040250E] System.TryHarder + $EE
[004026FE] System.SysGetMem + $196
[00491C6D] Forms.TApplication.CreateForm + $31
[0075DD97] LogView.LogView (Line 65, "C:\Delphi\Logview\LogView.dpr" + 20) + $E

#1 ♥ 0
4.4k Views 2 users read 3 min
support

Hi,

Do not create the LabelForm in case there is no printer installed.

Regards,

Julian

#2 ♥ 0

Hi Julian,

thx for your answer.

I tried something like this:

procedure TLabelDruckenForm.FormCreate(Sender: TObject);
var .....
begin
  if Printer.Printers.GetText = '' then exit;
  ....
end;

But this don´t seems to work. The error is still alive. Did you have a better solution?

#3 ♥ 0
support

WPTools 5 uses a variable

WPNoPrinterInstalled

which could be used. It is set by this code:

procedure WPCheckPrinterAvail;
var
  Flags, Count, NumInfo: DWORD;
  Level: Byte;
begin
  if Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
    Flags := PRINTER_ENUM_CONNECTIONS or PRINTER_ENUM_LOCAL;
    Level := 4;
  end
  else
  begin
    Flags := PRINTER_ENUM_LOCAL;
    Level := 5;
  end;
  Count := 0;
  EnumPrinters(Flags, nil, Level, nil, 0, Count, NumInfo);
  WPNoPrinterInstalled := (Count = 0);
end;

Julian

#4 ♥ 0
This category is archived. No new posts are possible.