Difference between revisions of "Documentation/DevGuide/Basic/Progress Bar"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
(Remove button code since it doesn't work and is not needed)
Line 13: Line 13:
 
   Sub ProgressBarDemo()
 
   Sub ProgressBarDemo()
 
       Dim oProgressBar As Object, oProgressBarModel As Object
 
       Dim oProgressBar As Object, oProgressBarModel As Object
      Dim oCancelButtonModel As Object
 
      Dim oStartButtonModel As Object
 
 
       Dim ProgressValue As Long
 
       Dim ProgressValue As Long
 
       REM progress bar settings
 
       REM progress bar settings
Line 22: Line 20:
 
       REM set minimum and maximum progress value
 
       REM set minimum and maximum progress value
 
       oProgressBarModel = oDialog.Model.ProgressBar1
 
       oProgressBarModel = oDialog.Model.ProgressBar1
       oProgressBarModel.ProgressValueMin = ProgressValueMin
+
       oProgressBarModel.setRange( ProgressValueMin, ProgressValueMax )
      oProgressBarModel.ProgressValueMax = ProgressValueMax
+
      REM disable cancel and start button
+
      oCancelButtonModel = oDialog.Model.CommandButton1
+
      oCancelButtonModel.Enabled = False
+
      oStartButtonModel = oDialog.Model.CommandButton2
+
      oStartButtonModel.Enabled = False
+
 
       REM show progress bar
 
       REM show progress bar
 
       oProgressBar = oDialog.getControl("ProgressBar1")
 
       oProgressBar = oDialog.getControl("ProgressBar1")
Line 34: Line 26:
 
       REM increase progress value every second
 
       REM increase progress value every second
 
       For ProgressValue =  
 
       For ProgressValue =  
              ProgressValueMin To ProgressValueMax Step ProgressStep
+
          ProgressValueMin To ProgressValueMax Step ProgressStep
           oProgressBarModel.ProgressValue = ProgressValue
+
           oProgressBarModel.setValue( ProgressValue )
 
           Wait 1000
 
           Wait 1000
 
       Next ProgressValue
 
       Next ProgressValue
 
       REM hide progress bar
 
       REM hide progress bar
 
       oProgressBar.setVisible( False )
 
       oProgressBar.setVisible( False )
      REM enable cancel and start button
 
      oCancelButtonModel.Enabled = True
 
      oStartButtonModel.Enabled = True
 
 
   End Sub
 
   End Sub
 
</source>
 
</source>

Revision as of 22:46, 22 November 2009



The progress bar control com.sun.star.awt.UnoControlProgressBar displays a growing or shrinking bar to give the user feedback during an operation, for example, the completion of a lengthy task. The minimum and the maximum progress value of the control is set by the ProgressValueMin and the ProgressValueMax properties. The progress value is controlled by the ProgressValue property. By default, the progress bar is blue, but the fill color can be changed by setting the FillColor property. The functionality of a progress bar is demonstrated in the following example:

  Sub ProgressBarDemo()
      Dim oProgressBar As Object, oProgressBarModel As Object
      Dim ProgressValue As Long
      REM progress bar settings
      Const ProgressValueMin = 0
      Const ProgressValueMax = 40
      Const ProgressStep = 4
      REM set minimum and maximum progress value
      oProgressBarModel = oDialog.Model.ProgressBar1
      oProgressBarModel.setRange( ProgressValueMin, ProgressValueMax )
      REM show progress bar
      oProgressBar = oDialog.getControl("ProgressBar1")
      oProgressBar.setVisible( True )
      REM increase progress value every second
      For ProgressValue = 
          ProgressValueMin To ProgressValueMax Step ProgressStep
          oProgressBarModel.setValue( ProgressValue )
          Wait 1000
      Next ProgressValue
      REM hide progress bar
      oProgressBar.setVisible( False )
  End Sub
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages