Meny
Index
Managing dialogue forms
In the previous example the second dialogue is displayed irrespective of whether "Have children" was checked. Let's show how to hide the second dialogue when this flag is unchecked. Create an “OnClick” handler for the ОК button on the first dialogue (double-click on the button to create the handler):
 
PascalScript:
 
procedure Button1OnClick(Sender: TfrxComponent);
begin
 DialogPage2.Visible := CheckBox1.Checked;
end;
 
C++Script:
 
void Button1OnClick(TfrxComponent Sender)
{
 DialogPage2.Visible = CheckBox1.Checked;
}
 
This code hides the second dialogue (DialogPage2) if the flag is not checked. Preview the report to see that this works correctly.
 
Another way of managing the forms is to use the “OnRunDialogs” report event. To create this event handler select the Report object in the report tree or object inspector and switch to the “Events” tab in the object inspector. Double-click on the “OnRunDialogs” event to create a handler:
 
 
Write the following code in the handler:
 
PascalScript:
 
procedure frxReport1OnRunDialogs(var Result: Boolean);
begin
 Result := DialogPage1.ShowModal = mrOk;
if Result then
begin
  if CheckBox1.Checked then
     Result := DialogPage2.ShowModal = mrOk;
end;
end;
 
C++Script:
 
void frxReport1OnRunDialogs(bool &Result);
{
 Result = DialogPage1.ShowModal == mrOk;
if (Result)
 {
  if (CheckBox1.Checked)
     Result = DialogPage2.ShowModal == mrOk;
 }
}
 
The handler works like this : the first dialogue is shown : if it is closed via the ОК button then look at the state of CheckBox1 : if this state is Checked then show the second dialogue : if the second dialogue is closed via the ОК button then set Result to True. If the handler returns Result = True then the preview is built : if Result = False then the report stops running without building a preview.
Onlinehjälpen skapades med Dr.Explain