Thread: Progress Bar
View Single Post
  #2  
Old 11-02-2004, 08:23
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Progress Bar

It's very difficult to do this in VBA because once you have a modal form (your main dialog) you cannot show another form as modeless. You can only show another modal form (a modal form means that it takes up the control until it is closed).

To work around it you either put the progress bar to your main form or move the actual processing code for to the secondary form.

By the way, in Draw 12 it is now possible to use CorelDRAW's status bar to show progress, which eliminates problem altogether:

Code:
Sub ShowProgress()
    Dim doc As Document
    Dim stat As AppStatus
    Dim n As Long
    
    Set doc = CreateDocument
    Set stat = Application.Status
    stat.BeginProgress CanAbort:=True
    For n = 1 To 1000
        doc.ActiveLayer.CreateRectangle2 Rnd() * 8, Rnd() * 11, Rnd() * 5, Rnd() * 5
        If (n Mod 10) = 0 Then
            stat.UpdateProgress
            If stat.Aborted Then Exit For
        End If
    Next n
    stat.EndProgress
End Sub
The above code creates 1000 random rectangles and shows the progress bar as it goes. The process also can be aborted by pressing Esc key.
Reply With Quote