Dialog form - updating label control

edited 7:00PM in FastReport 4.0
Hi

I'm using an application which uses Fast Reports as the reporting tool. I'm using Pascal script for the scripting.
I am generating the data required for the report from a button in a dialog form with the button set as ModalResult = mrOK.

I am trying to update the caption of a label on the form to notify the user of the progress of the data generation. The gathering of the data takes quite a while, so I want the user to see the progress.

However the label caption does not update.
If I put a showmessage( 'status update') statement immediately after the statement which updates the label's caption, , then the label caption on the form refreshes.

Is there any way of forcing the form to update the label caption?
Any other ideas of notifying the user as to the progress of the data (not report/page) generation would be appreciated.

Thanks

Comments

  • edited 7:00PM
    Try this:
    procedure BitBtn1OnClick(Sender: TfrxComponent);
    var MyForm   :TForm;                                                                        
        MyLabel  :TLabel;
        i :int;                     
    begin
        MyForm := TForm.Create(  Report);
        MyForm.Caption  := 'Progres bar ...';                                                  
        MyForm.Width    := Int(10 * fr1cm);
        MyForm.Height   := Int( 4 * fr1cm);
        MyForm.Position := poScreenCenter;                                                         
        MyLabel         := TLabel.Create( MyForm);
        MyLabel.Parent  := MyForm;                                                                
        MyLabel.Left    := 10;
        MyLabel.Top     := 10;
        MyLabel.Width   := 100;
        MyLabel.Height  := 20;                                                        
        MyForm.Visible  := true;
    
        for i:=1 to 10 do begin
          MyLabel.Caption := 'this is step no: ' + IntToStr(i);
          ShowMessage('Next step ...');                                                                            
        end;              
        MyForm.Visible  := false;
    
    end;
    

    Mick
  • edited 7:00PM
    Hi Mick

    Thanks for the suggestion.

    However when I remove the ShowMessage('Next step ...') line (I don't want this as the user would have to click through each message), the label's caption still does not update (which is exactly what I was experiencing without creating a new form).

    What I noticed was I can change the myform.caption and this refreshes - however this is not ideal.
  • Anu de DeusAnu de Deus Hampshire, UK
    edited 7:00PM
    just delete the showmessage and put this instead:
    MyLabel.update;
  • edited 7:00PM
    just delete the showmessage and put this instead:
    MyLabel.update;

    There is no update method - Getting an error - Unidentified identifier: 'Update'
  • gpigpi
    edited 7:00PM
    Add ProcessMessages function in FS:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
         frxReport1.AddFunction('function ProcessMessages');
         frxReport1.ShowReport();
    end;
    
    function TForm1.frxReport1UserFunction(const MethodName: string;
      var Params: Variant): Variant;
    begin
         if MethodName = 'PROCESSMESSAGES' then Application.ProcessMessages;
    
    end;
    
    and replace ShowMessage('Next step ...'); with ProcessMessages in report's script
  • edited 7:00PM
    gpi wrote: »
    Add ProcessMessages function in FS:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
         frxReport1.AddFunction('function ProcessMessages');
         frxReport1.ShowReport();
    end;
    
    function TForm1.frxReport1UserFunction(const MethodName: string;
      var Params: Variant): Variant;
    begin
         if MethodName = 'PROCESSMESSAGES' then Application.ProcessMessages;
    
    end;
    
    and replace ShowMessage('Next step ...'); with ProcessMessages in report's script

    Thanks! I simply added application.processmessages after the label.caption := line and the label now updates.
    Appears as if you need application.processmessages to update label captions but not form caption.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.