Home RAP

sendtoback

edited February 2010 in RAP
Hi again,

in my report, I have 2 components: tppLine and tppDBText, both are
transparent.

The DBText is overlaying tppLine and i want to send it back, when i click on
it. To bring it back to front, I also send to tppline to back, when i click
on it.

Here is the script of the tppLine.onDrawCommandClick-Event:


begin
ShowMessage('line');
line1.sendToBack;
end;

and for the tppDBText-component:
begin
ShowMessage('dbText');
DBText1.sendToBack;
end;



It doesn't work.

As I found here, the DrawComand.RedrawPage has to be set outside of RAP. So
I decided like this:

begin
ShowMessage('line');
executeMyFunc (line1, tppDrawCommand(aDrawcommand));
end;


executeMyFunc is declared as (signature)
procedure executeMyFunc (aComponent: tppComponent; aDrawCommand:
tppDrawCommand);

...
var
lComponent: tppComponent;
lDrawCommand: tppDrawCommand;
begin
GetParamValue(0, lComponent);
GetParamValue(1, lDrawCommand);

if not (lComponent = nil) then begin
lComponent.SendToBack;
if not (lDrawCommand = nil) then begin
lDrawCommand.RedrawPage:= true;
SetParamValue(1, lDrawCommand);
end;
end;
end;


It doesn't work.

Any idea ?

(ReportBuilder 10, Delpi 7)

Thanks in advance

Marion

Comments

  • edited February 2010
    Hi Marion,

    Try resetting the TppReport and the TppReport.Engine before setting
    RedrawPage to true. Similar to what is done in the following example.

    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Formatting/How_To...Refresh_the_Report_After_a_Drawcommand_Click

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2010
    Sorry, but no sucess yet.

    I modified my Delphi-code as follows:

    ////////////////////////////////////////////////////////////////////////////////
    Class function TmyTestFunction.Category: string;
    begin
    Result := cCategoryAOFormulare;
    end;

    Class function TmyTestFunction.GetSignature: string;
    begin
    Result:= 'procedure ExecuteMyFunc(aComponent: tppComponent; aDrawCommand:
    tppDrawCommand);';
    end;

    procedure TmyTestFunction.ExecuteFunction(aParams: TraParamList);
    var
    lComponent: tppComponent;
    lDrawCommand: tppDrawCommand;
    begin
    GetParamValue(0, lComponent);
    GetParamValue(1, lDrawCommand);
    if not (lcomponent = nil) then begin
    lComponent.SendToBack;
    lComponent.Report.MainReport.Reset;
    lComponent.Report.MainReport.Engine.Reset;

    if not (lDrawCommand = nil) then begin
    lDrawCommand.RedrawPage:= true;
    SetParamValue(1, lDrawCommand);
    end;
    end;
    end;
    ////////////////////////////////////////////////////////////////////////////////


    begin
    ShowMessage('line');
    ExecuteMyFunc(Line1, tppDrawCommand(aDrawCommand));
    end;

  • edited February 2010
    Hi Marion,

    I suggest you get this working in Delphi first then try moving it to RAP.
    In my testing with Delphi code, it worked as expected.

    My first suggestion for changes to your pass thru function would be to pass
    the report object as well so you can call Reset and Engine.Reset directly.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2010
    Even with passing the report to the pass thru function, I don't get success.

    Simple in Delphi, it seems to work fine.

    I've got a form, containing a viewer and a simple button to change the
    front-back-order of the 2 Objects.
    The script for the button-clickedEvent :
    ..
    begin
    if iTest = 0 then begin
    lTest:= tppComponent(self.ppViewer1.Report.FindUserObject('line2'));
    iTest:= 1;
    end else begin
    lTest:= tppComponent(self.ppViewer1.Report.FindUserObject('sb_name'));
    iTest:= 0;
    end;

    if not (lTest = nil) then begin
    ShowMessage(lTest.UserName);
    lTest.SendToBack;

    tppCustomReport(self.ppViewer1.Report).Reset;
    tppCustomReport(self.ppViewer1.Report).Engine.Reset;
    tppCustomReport(self.ppViewer1.Report).PrintToDevices;
    end;
    end;

    Any other idea ?

    Marion

  • edited February 2010
    Hi Marion,

    This is working for me.

    1. Download the RAP example from the rbWiki article.
    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Formatting/How_To...Refresh_the_Report_After_a_Drawcommand_Click

    2. Open the design of this report and add two overlapping rectangles to the
    footer band.

    3. In the Calc tab implement the OnDrawCommandClick event of the front-most
    shape with the following code...

    begin
    Shape2.SendToBack;

    Reset(Report, TppDrawCommand(aDrawCommand));
    end;

    4. Run the application and preview the report. Click the front shape...
    voila :).

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2010
    Ok, when I only place this script of the front-most shape, it seems to work
    fine - of cours, once only.

    But the code in the onDrawCommandClick event of the second shape will not
    fire. It just seems to be in the background, but when clicking again, the
    OnDrawCommand of the first shape is fired again.

    Our users can modify several attributes of predefined components, e.g.
    position, colour etc.

    In the OnDrawCommandClick of these components, I call a pass-thru function
    in which I open a special dialog. Sometimes the user declare wrong positions
    of their objects and move one over the other.

    To get access to objects in the background, the user shoud be able to send
    the front-most (currently-clicked) component to back.

    Sorry for my english, I hope, you understand..

    Marion


  • edited February 2010
    Hi Marion,

    The OnClick event is not designed to differentiate between "front" and
    "back" report components. ReportBuilder created the clickable area based on
    when the event is assigned (first in the z-order).

    To work around this, just implement a single OnDrawCommandClick event and
    control both components from there. Something like the following...

    if ppShape1.ZOrder > ppShape2.ZOrder then
    ppShape1.SendToBack
    else
    ppShape2.SendToBack;

    reset;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.