🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.language.delphi.general
2 messages
2 total messages Started by Kalle Lakemountain Thu, 22 Apr 2010 23:57
Problems getting correct printout from treeview on screen to Reportbuilder
#147
Author: Kalle Lakemountain
Date: Thu, 22 Apr 2010 23:57
312 lines
10593 bytes
 I have ”inherited” a Delphi application that I’m supposed to
maintain. Since I have no major experience in programming using Delphi
it is quite a challenge.

Now I have a problem that I have been occupied with for some days. I
have tried different changes and been using debugger intensively but I
have not come to a conclusion what is being wrong. The problem is that
when trying to send a printout to a printer the preview(and printout)
does not show the same as the screen in the application shows. The
application shows a tree view with different levels visible but when
sending to printer some of the expanded nodes are shown as a collapsed
nodes. This can most often be observed in the node called ‘Order level
1’ below in Example 1.

Example 1 of the layout in the application:

        Search result
                 -	Order level 1
                         - Sublevel 1
	             + North
	             + East
	             + West
                       + Sublevel 2
	   + Sublevel 3


The output to printer layout:

Search result
          - Order level 1
                  + Sublevel 1
                  + Sublevel 2
                  + Sublevel 3

===================================================
Example 2 from the application screen:

Search result
         - Order level 1
                  + Sublevel 1
                  -  Sublevel 2
                             - South
	               + Sunshine
	               + Moonlight
                                   + Rain
                                   + Snow
                  + Sublevel 3





The print output layout

Search result
          - Order level 1
                  + Sublevel 1
                  -  Sublevel 2
                           + South
                  + Sublevel 3


If  a second attempt is done(without doing anything else before ) to
send Example 2 to the printer the print output layout looks the same
as on the screen. Example 1 does always look the same though no
mattter how many times sending to printer is done.


I have found the functions that are involved in creating the list of
the tree view from the screen and reading the list and loading the
information in Reportbuilder 6.03 for creating the report to be sent
to the printer. I am running Delphi 6 update 2 and TExtradevice.

When debugging the function TReports_Form.InboxTreeGetFieldValue(const
aFieldName: String):Variant(where the reading from the ListTree
TStringList and sending to Reportbuilder is done) I have noticed that
Result returns(using Example 1) sublevel 1, 2 and 3  three times each
and “Search Result” is returned seven times – I don’t really
understand why this many times when creating the report. Is this an
ordinary way to build tree views or might it be a bug?

Is there anyone who has experienced this kind of problems and maybe
can point out some obvious error in the programming in the
TReports_Form.InboxTreeGetFieldValue function or might it be a bug in
Reportbuilder? All ideas and tips regarding what to check are
welcome:-).


Regards,
Kalle


Some code:

When the printout is initiated it starts with the function Addlist
called like this Listtree:=Addlist(GetFirstNode, true, true).
Listtree is a TStringList. GetFirstNode returns "Search result".


function AddList(parentNode: TTreeNode; isCaption: boolean;
firstNode:boolean):TStringList;
var
  tmpList: TStringList;
  currNode, childNode: TTreeNode;
  infoNode: ^Node;
begin
  tmpList := TStringList.Create;
  childNode := nil;

  if parentNode = nil then
    currNode := nil
  else
  if not parentNode.Expanded or firstNode then
  begin
    if not parentNode.Expanded then
      childNode := nil
    else
      childNode := parentNode.getFirstChild;
    currNode := parentNode;
  end
  else
  begin
    currNode := parentNode;
    childNode := parentNode.getFirstChild;
  end;

  while currNode <> nil do
  begin
    infoNode := currNode.Data;
    if isCaption then
      tmpList.AddObject(infoNode^.caption,AddList(childNode,true,
false))
    else
 
tmpList.AddObject(IntToStr(Ord(infoNode^.icon)),AddList(childNode,false,
false));
    currNode := currNode.getNextSibling;
    if currNode <> nil then
      if currNode.Expanded then
        childNode := currNode.getFirstChild
      else
        childNode := nil;
  end;

  Result := tmpList;
end;

====================================================


InboxTree2_JITPipeline: TppJITPipeline;
    InboxTree3_JITPipeline: TppJITPipeline;
    InboxTree4_JITPipeline: TppJITPipeline;
    InboxTree5_JITPipeline: TppJITPipeline;

InboxTree1_JITPipeline.RecordCount := 1;
  InboxTree2_JITPipeline.RecordCount := 1;
  InboxTree3_JITPipeline.RecordCount := 1;
  InboxTree4_JITPipeline.RecordCount := 1;
  InboxTree5_JITPipeline.RecordCount := 1;
  tmpList2 := TStringList.Create;
  tmpList3 := TStringList.Create;
  tmpList4 := TStringList.Create;
  tmpList5 := TStringList.Create;
  IconList2 := TStringList.Create;
  IconList3 := TStringList.Create;
  IconList4 := TStringList.Create;
  IconList5 := TStringList.Create;





function TReports_Form.InboxTree1_JITPipelineGetFieldValue(
  aFieldName: String): Variant;
begin
  Result := InboxTreeGetFieldValue(aFieldName);
end;


function TReports_Form.InboxTreeGetFieldValue(const aFieldName:
String):Variant;
var
  lsFieldName: String;
Begin

  lsFieldName := UpperCase(aFieldName);
  if (lsFieldName = 'INBOXHEADER') then
    Result := InboxHeader
  else if (lsFieldName = 'TREECAPTION1') then
  begin
    tmpList2 := nil;
    tmpList3 := nil;
    tmpList4 := nil;
    tmpList5 := nil;
    IconList2 := nil;
    IconList3 := nil;
    IconList4 := nil;
    IconList5 := nil;
    if ListTree.Objects[InboxTree1_JITPipeline.RecordIndex] <> nil
then
    begin
      tmpList2 := ListTree.Objects[InboxTree1_JITPipeline.RecordIndex]
as TStringList;
      IconList2 :=
IconTree.Objects[InboxTree1_JITPipeline.RecordIndex] as TStringList;
      InboxTree2_JITPipeline.RecordCount := tmpList2.Count;
    end
    else
    begin
      InboxTree2_JITPipeline.RecordCount := 0;
    end;

    Result := ListTree.Strings[InboxTree1_JITPipeline.RecordIndex];
  end
  else if (lsFieldName = 'TREECAPTION2') then
  begin
    tmpList3 := nil;
    tmpList4 := nil;
    tmpList5 := nil;
    IconList3 := nil;
    IconList4 := nil;
    IconList5 := nil;
    if (tmpList2 <> nil) and (tmpList2.count <> 0) then
    begin
      if tmpList2.Objects[InboxTree2_JITPipeline.RecordIndex] <> nil
then
      begin
        tmpList3 :=
tmpList2.Objects[InboxTree2_JITPipeline.RecordIndex] as TStringList;
        IconList3 :=
IconList2.Objects[InboxTree2_JITPipeline.RecordIndex] as TStringList;
        InboxTree3_JITPipeline.RecordCount := tmpList3.Count;
      end
      else
      begin
        InboxTree3_JITPipeline.RecordCount := 0;
      end;
        Result :=
tmpList2.Strings[InboxTree2_JITPipeline.RecordIndex];
    end
    else
       Result := '';
  end
  else if (lsFieldName = 'TREECAPTION3') then
  begin
    tmpList4 := nil;
    tmpList5 := nil;
    IconList4 := nil;
    IconList5 := nil;
    if (tmpList3 <> nil) and (tmpList3.count <> 0) then
    begin
      if tmpList3.Objects[InboxTree3_JITPipeline.RecordIndex] <> nil
then
      begin
        tmpList4 :=
tmpList3.Objects[InboxTree3_JITPipeline.RecordIndex] as TStringList;
        IconList4 :=
IconList3.Objects[InboxTree3_JITPipeline.RecordIndex] as TStringList;
        InboxTree4_JITPipeline.RecordCount := tmpList4.Count;
      end
      else
      begin
        InboxTree4_JITPipeline.RecordCount := 0;
      end;
        Result :=
tmpList3.Strings[InboxTree3_JITPipeline.RecordIndex];
    end
    else
      Result := '';
  end
  else if (lsFieldName = 'TREECAPTION4') then
  begin
    tmpList5 := nil;
    IconList5 := nil;
    if (tmpList4 <> nil) and (tmpList4.count <> 0)then
    begin
      if (tmpList4.Objects[InboxTree4_JITPipeline.RecordIndex] <> nil)
then
      begin
        tmpList5 :=
tmpList4.Objects[InboxTree4_JITPipeline.RecordIndex] as TStringList;
        IconList5 :=
IconList4.Objects[InboxTree4_JITPipeline.RecordIndex] as TStringList;
        InboxTree5_JITPipeline.RecordCount := tmpList5.Count;
      end
      else
      begin
        InboxTree5_JITPipeline.RecordCount := 0;
      end;
         Result :=
tmpList4.Strings[InboxTree4_JITPipeline.RecordIndex];
    end
    else
      Result := '';
  end
  else if (lsFieldName = 'TREECAPTION5') then
  begin
    if (tmpList5 <> nil) and (tmpList5.count <> 0) then
      Result := tmpList5.Strings[InboxTree5_JITPipeline.RecordIndex]
    else
      Result := '';
  end
  else if (lsFieldName = 'TYPEICON1') then
    Result := ''
  else
    Result := '';
end;
Re: Problems getting correct printout from treeview on screen to Reportbuilder
#148
Author: Kalle Lakemountain
Date: Fri, 23 Apr 2010 00:04
54 lines
3173 bytes
>
> Example 1 of the layout in the application:
>
>         Search result
>                  - Order level 1
>                           - Sublevel 1
>                                 + North
>                                 + East
>                                 + West
>                          + Sublevel 2
>                          + Sublevel 3
>
> The output to printer layout:
>
> Search result
>           - Order level 1
>                   + Sublevel 1
>                   + Sublevel 2
>                   + Sublevel 3
>
> ===================================================
> Example 2 from the application screen:
>
> Search result
>          - Order level 1
>                   + Sublevel 1
>                   -  Sublevel 2
>                              - South
>                                    + Sunshine
>                                    + Moonlight
>                                    + Rain
>                                    + Snow
>                   + Sublevel 3
>
> The print output layout
>
> Search result
>           - Order level 1
>                   + Sublevel 1
>                   -  Sublevel 2
>                            + South
>                   + Sublevel 3
>




Ooops seems like the indentation in the examples did not work - hope
it looks better this time....
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads