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

From Apache OpenOffice Wiki
Jump to: navigation, search
(Remove button code since it doesn't work and is not needed)
(Sample code works when copied and pasted into Basic)
Line 11: Line 11:
 
<!--[SOURCE:BasicAndDialogs/ToolkitControls/ProgressBar.xba]-->
 
<!--[SOURCE:BasicAndDialogs/ToolkitControls/ProgressBar.xba]-->
 
<source lang="oobas">
 
<source lang="oobas">
  Sub ProgressBarDemo()
+
Sub ProgressBarDemo()
      Dim oProgressBar As Object, oProgressBarModel As Object
+
Dim oProgressBar as Object, oProgressBarModel As Object, oDialog as Object
      Dim ProgressValue As Long
+
Dim ProgressValue As Long
      REM progress bar settings
+
REM Dialog1 contains progress bar ProgressBar1 saved in standard library
      Const ProgressValueMin = 0
+
DialogLibraries.loadLibrary("Standard")
      Const ProgressValueMax = 40
+
oDialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
      Const ProgressStep = 4
+
REM progress bar settings
      REM set minimum and maximum progress value
+
Const ProgressValueMin = 0
      oProgressBarModel = oDialog.Model.ProgressBar1
+
Const ProgressValueMax = 40
      oProgressBarModel.setRange( ProgressValueMin, ProgressValueMax )
+
Const ProgressStep = 4
      REM show progress bar
+
REM set minimum and maximum progress value
      oProgressBar = oDialog.getControl("ProgressBar1")
+
oProgressBarModel = oDialog.getModel().getByName( "ProgressBar1" )
      oProgressBar.setVisible( True )
+
oProgressBarModel.setPropertyValue( "ProgressValueMin", ProgressValueMin)
      REM increase progress value every second
+
oProgressBarModel.setPropertyValue( "ProgressValueMax", ProgressValueMax)
      For ProgressValue =  
+
REM show progress bar
          ProgressValueMin To ProgressValueMax Step ProgressStep
+
oDialog.setVisible( True )
          oProgressBarModel.setValue( ProgressValue )
+
REM increase progress value every second
          Wait 1000
+
For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
      Next ProgressValue
+
oProgressBarModel.setPropertyValue( "ProgressValue", ProgressValue )
      REM hide progress bar
+
Wait 1000
      oProgressBar.setVisible( False )
+
Next ProgressValue
  End Sub
+
End Sub
 
</source>
 
</source>
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]

Revision as of 03:36, 26 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, oDialog as Object
	Dim ProgressValue As Long
	REM Dialog1 contains progress bar ProgressBar1 saved in standard library
	DialogLibraries.loadLibrary("Standard")
	oDialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
	REM progress bar settings
	Const ProgressValueMin = 0
	Const ProgressValueMax = 40
	Const ProgressStep = 4
	REM set minimum and maximum progress value
	oProgressBarModel = oDialog.getModel().getByName( "ProgressBar1" )
	oProgressBarModel.setPropertyValue( "ProgressValueMin", ProgressValueMin)
	oProgressBarModel.setPropertyValue( "ProgressValueMax", ProgressValueMax)
	REM show progress bar
	oDialog.setVisible( True )
	REM increase progress value every second
	For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
		oProgressBarModel.setPropertyValue( "ProgressValue", ProgressValue )
		Wait 1000
	Next ProgressValue
End Sub
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages