Hi All,
A while ago, i put an app together which includes a windows form to display a marquee progress bar & a company logo during a long process. This worked fine with AutoCAD 2010 on XP Pro.
However, I am having problems with it on the latest versions of AutoCAD (2012+) on Win 7 (not tried on 8).
When the form appears the progressbar is not activated & is blank.
I have attached an example project which you can try.
It uses standard windows techniques which work fine outside of AutoCAD ie setting the progressbar style to Marquee.
The project is built on AutoCAD 2012 & targets dotnet version 4.
Any help greatly appreciated.
Steve
A ModelDialog is not good for displaying progress, Modeless is what you need.
I have no problem using modal forms to display progress updates, in any release.
If you want a progress dialog that blocks access to AutoCAD, you can use a modal dialog for that. With a modeless dialog, the user has access to AutoCAD's UI, which you may not want. A modal progress dialog can also show a button that allows the user to cancel the process if that's appropriate.
See the attached sample. If you run it, you'll need a drawing with a large number of objects.
It really depends what you need, so whatever works 🙂
Thanks for the replies. Just to fill you in a little more:
The application which I mention is a quite large & comprehensive piece of code written in Visual Lisp (because that is my background). During execution, a schedule of data contained in the drawing is compiled into a table & placed into the drawing. The size & the amount of data written into the table is determined at runtime. As this process is being carried out, I want to show a dialog which contains a Marquee Progress Bar so the user can see that the process of drawing the table is taking place (the table may not be in the screen view) & it can take a minute or two. My solution to this was to have the VLisp code call a dll function to display the Marquee dialog, call the VLisp function to draw the table then close the dialog when the table had been completed. Hence the need for a Marquee Progress Bar. The problem I have is activating the Progress Bar.
DiningPhilospher, I played around with your original example, changing the progressbar style to Marquee and commented out the "LongProcess" call (as i dont need to do anything in my function). What this did was display the dialog with the Marquee working & the "Sucessfull" alert box over the top iof it...great, the Marquee works! I then went one step further & replaced the "if" statement with a "sleeping" thread thinking i would get a scrolling Marquee dialog but no...the progressbar was not activated. Would it be possible you to post an example of the best way to achieve this?
Steve
Well, everything your code does runs on the same UI thread as the AutoCAD operation. So, if you call thread.Sleep(), guest what, AutoCAD pauses, so as whatever on your form.
If I have to show progress in a form, I'd prefer using modal dialog box to modeless dialog box. In my experiece, the modeless dailog box may not get refreshed well, just like AutoCAD itself looks like frozen when it is busy. With modal dialog, one can call System.Windows.Forms.Application.DoEvents() to force form/control refresh, hence better visual effect.
Of course, when using modal dialog, we should try to avoid to mix AutoCAD processing code with the dialog box code together. And better yet, it is desired that the modal dialog box for process can be more generic and re-usable.
I posted an article on this quite a while ago on this topic that may be of help to you (you can set the progress bar as "Marquee" with some minor code change, I suppose):
http://drive-cad-with-code.blogspot.ca/2010/12/showing-progress-window-when-running.html
To be warned, though, adding progress window as modal dialog and force its refresh may slow down the execution of your code (because updating window's graphic is expensiv) even though the visual progress bar may fool user to thing the processing is fast.
Norman Yuan
I feel that he'll get best results invoking a modeless dialog and updating it.
If not, he can get round the Sleep() issue by wrapping it in a backgroundworker.
Another option is to use the ProgressBar class.
@fenton.webb wrote:I feel that he'll get best results invoking a modeless dialog and updating it.
If not, he can get round the Sleep() issue by wrapping it in a backgroundworker.
Another option is to use the ProgressBar class.
Hi Fenton.
There's really no need for calling Sleep(). I posted an example that shows that.
The OP is using the ProgressBar class.