Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

ElXTree Printing: OnItemPrinting: Setting Print = False causes infinite loop

Here is the code.

The first item is not selected and so Print is set to False.

The printing machine does not move on from this record. 
It is always the first record.

If I change the value to True in the debugger, then the next item is processed.

This is most likely a bug that needs to be fixed.

Is it a bug, and if so, when will it be fixed?

Regards,
Raymond

procedure TMainForm.ItemTreePrinterItemPrinting(Sender: TObject;
  Item: TElXTreeItem; var Print: Boolean);
begin
  if    (PrintMode = amSelected)
    and (not Item.Selected) then
  begin
    Print := False;
  end
  else
  begin
    Print := True;

    with Item do
    begin
      Cells[2].Text := Format('%8s', [Trim(Cells[2].Text)]);

      Cells[4].Text := '';
      Cells[5].Text := '';
      Cells[6].Text := '';
    end;
  end;
end;

Comments

  • 3 Comments sorted by Votes Date Added
  • edited March 2013 Posts: 0 Accepted Answer Vote Up0Vote Down
    Hi Raymond,

    Thank you for this report. Indeed, it was a bug, it is fixed now.
    However, information what items are selected are not passed to tree printer, so Item.Selected is always false in ItemPrinting event. As  workaround, you can use some preprocessing before printing, e.g. setting Tag to 1 for all selected items. 
    Meanwhile, I'll check out if we can fix issue with passing info about current items selection to tree printer.

    Best regards,
    Victor Bocharov
    bocharov@lmd.de
  • Setting the Tag to 1 would be ok if the infinite loop didn't occur.

    When will the trial version for the new code be available?

    Thanks.

    Raymond
Sign In or Register to comment.