From Cory Eicher

Wednesday, February 08, 2006

Making Progress

A more accurate title for today's entry might have been 'Showing Progress'.

In writing some VB code recently, I found two things in ArcObjects that made what I was doing much easier than similar functionality in vanilla VB. Both involve providing progress feedback to the user.

Exhibit A - Showing Progress While Exporting:
To get an image or vector graphic out of ArcMap, you can use IExport. So, for example you can export from the data view to get 'just the data', or you can export from layout view to get 'the whole map', including map elements such as graphics, scale bars (not sure why you'd need more than one ; ) , etc. You probably already knew this... There's a good sample here:

(esri edn) Export Active View to JPEG Sample

What you might not have known is that there's a really easy way to show progress when exporting. If you're like me, you might not want to monkey around with creating your own logic for showing progres... So, just do this:

IExport has a property StepProgressor. This property expects an object that supports, you guessed it, IStepProgressor. More importantly, the ArcMap framework has a status bar that has a progress bar that supports this interface. So, all you need to do is get ahold of the ArcMap application thru IApplication and connect its progress bar to the export object like this.

Dim pApp as IApplication
Set pApp = Application
Set pExport.StepProgressor = pApp.StatusBar.ProgressBar


Then, go ahead with your export. Your users will see export progress in the ArcMap status bar (lower left of the ArcMap window).

Exhibit B - Showing a Wait Mouse Cursor:
ArcObjects has its own MouseCursor object. For what I was doing today, I found it to be very convenient.

Dim pMouseCursor As IMouseCursor
Set pMouseCursor = New MouseCursor
pMouseCursor.SetCursor 2 ' wait cursor (gets reset automatically at end of sub)

Talk to you soon,

-Cory

www.eicher-gis.com

0 Comments:

Post a Comment

<< Home