Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

It turns out that the best way to run long tasks in ArcMap is to use the IProgressDialog2. The BackgroundWorker in combination with ArcObjects (STA Threads) is a mess.

However, it seems that the only implementation from ESRI is the IStepProgressor. In my case I do not need and do not want to show a progress bar. Moreover I do not need the cancel button. Is there a way to remove both things? I want only the text and the circle as you can see in my screenshot my progress dialog

public static void ShowProgressDialog<T>(string message, Action<T> action, T arg)
    {

        ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass();

        ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass();

        // Set the properties of the Step Progressor
        System.Int32 int32_hWnd = ArcMap.Application.hWnd;
        ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);


        ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog2 = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

        progressDialog2.CancelEnabled = false;
        progressDialog2.Description = message;
        progressDialog2.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;

        action.Invoke(arg);

        trackCancel = null;
        progressDialog2.HideDialog();
        progressDialog2 = null;

    }
share|improve this question
1  
No, the progress dialog was not designed for such customizability. I guess since the dialog you are looking for is pretty plain, should be rather easy in WPF or WinForms to implement it yourself. –  Petr Krebs Dec 23 '12 at 11:24
    
I suppose if you really wanted to you could hack the dialog with Windows API calls but meh... –  blah238 Dec 24 '12 at 1:15
    
Apart from the threading problem it would be even harder to implement a custom busy indicator that blocks the complete ArcMap GUI. You get it for free with the IProgressDialog2... –  steffan Dec 27 '12 at 2:45
add comment

2 Answers 2

up vote 3 down vote accepted

I agree about using the IProgressDialog2 with ArcGIS over other methods of showing progress. It always seems more reliable. I often use it for long running queries where I want to give the user the ability to cancel but don't know how long the query will take. In these cases I instantiate the dialog just like you do but before calling the action I simply hide the step progressor. The rest of the dialog will function and appear as normal. Add this just before you invoke the action:

stepProgressor.Hide();
progressDialog2.ShowDialog();

I don't know of a way to remove the cancel button.

share|improve this answer
    
Thank you! That was exactly what I was looking for. I think/hope the user can live with the cancel button. At least it is possible to disable the button. –  steffan Dec 27 '12 at 15:13
add comment

Cast the ProgressDialog as IProgressor to .Hide the progressor. Cast to IProgressDialog to set CancelEnabled to true.

share|improve this answer
    
Hiding the progressor is a duplicate of my answer Jason. Setting CancelEnabled to true does not remove the cancel button as the OP desired. –  Rich Wawrzonek Dec 26 '12 at 19:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.