How to trap Cancel press event for a progress bar

havhav Member Posts: 299
Hi all,
I have created a dialog window to display progress bar. The progress bar is working fine

When the progress bar is running and if i press Cancel button on the dialog window, it closes the dialog and terminates any further processing.

What i want to know is how to trap the Cancel button press event while updating the progress bar on a dialog window.

What exactly happens when this event takes place?

Pls answer to the above questions if any one of you know this.

Regards,
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Comments

  • matttraxmatttrax Member Posts: 2,309
    Never actually done it, but I think it would be something like this.

    Your progress bar has a variable that updates until it reaches 100, lets call it counter. If you press the Cancel button then the counter will not be 100 when the next line executes.

    So right before the code that executes after the Dialog is supposed to close you could put:
    IF Counter <> 100 THEN //I got here without finishing the processing
      CancelCleanUp() //Or whatever code you want to use
    

    I hope that helps
  • havhav Member Posts: 299
    First of all thanks for your help.

    I agree with you but the doubt still remains.

    I am not sure where exactly within the loop the condition to rollback and skip further processing should be written.

    For example:-
    Open Progress Bar dialog
    
    Fetch first record
    Repeat
       do some processing
       update count of records
       Update progress bar
    Untill Next record exists
    
    Do further processing
    
    

    On pressing Cancel on progress bar,
    Q --> The control goes to which statement?
    Q --> Does Navision exits the loop?
    Q --> Any processing carried out so far is rolled back?
    Q --> Any further processing is carried out?

    Pls reply to above questions

    Regards,
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • David_SingletonDavid_Singleton Member Posts: 5,479
    hav wrote:
    Hi all,
    I have created a dialog window to display progress bar. The progress bar is working fine

    When the progress bar is running and if i press Cancel button on the dialog window, it closes the dialog and terminates any further processing.

    What i want to know is how to trap the Cancel button press event while updating the progress bar on a dialog window.

    What exactly happens when this event takes place?

    Pls answer to the above questions if any one of you know this.

    Regards,

    This is all covered by the Version Principle, there is no "roll back" in Navision. All you need to do is write code according to the NAV guidelines, and all will be fine.
    David Singleton
  • absolutelyfreewebabsolutelyfreeweb Member Posts: 104
    I may be wrong but I imho the dialog box cancel button is designed incompletely.

    If you use a progressbar for a task where the outcome is not given, you normally want to close it when either you complete your task, or when the progressbar is finished and it times out. Now when you check if you are finished and want to close the bar, the user might alraedy have closed it with the cancel button. There is no way to know that its not there, and the close function doesnt work with "if" and it throws an error. This is really a design error, the close function should allow a "if not dialog.close()" check and not throw an error.

    What do you think?
  • MalajloMalajlo Member Posts: 294
    What about

    If not DoSomeProcessing then DoSomethingElse

    Function: DoSomeProcessing(return:boolean)
    Dialog.Open
    ...
    exit(TRUE)
Sign In or Register to comment.