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

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
(3 intermediate revisions by one other user not shown)
Line 10: Line 10:
 
The progress bar control <idl>com.sun.star.awt.UnoControlProgressBar</idl> 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 <code>ProgressValueMin</code> and the <code>ProgressValueMax</code> properties. The progress value is controlled by the <code>ProgressValue</code> property. By default, the progress bar is blue, but the fill color can be changed by setting the <code>FillColor</code> property. The functionality of a progress bar is demonstrated in the following example:  
 
The progress bar control <idl>com.sun.star.awt.UnoControlProgressBar</idl> 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 <code>ProgressValueMin</code> and the <code>ProgressValueMax</code> properties. The progress value is controlled by the <code>ProgressValue</code> property. By default, the progress bar is blue, but the fill color can be changed by setting the <code>FillColor</code> property. The functionality of a progress bar is demonstrated in the following example:  
 
<!--[SOURCE:BasicAndDialogs/ToolkitControls/ProgressBar.xba]-->
 
<!--[SOURCE:BasicAndDialogs/ToolkitControls/ProgressBar.xba]-->
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
  Sub ProgressBarDemo()
+
Sub ProgressBarDemo()
      Dim oProgressBar As Object, oProgressBarModel As Object
+
Dim oProgressBar as Object, oProgressBarModel As Object, oDialog as Object
      Dim oCancelButtonModel As Object
+
Dim ProgressValue As Long
      Dim oStartButtonModel As Object
+
REM Dialog1 contains progress bar ProgressBar1 saved in standard library
      Dim ProgressValue As Long
+
DialogLibraries.loadLibrary("Standard")
      REM progress bar settings
+
oDialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
      Const ProgressValueMin = 0
+
REM progress bar settings
      Const ProgressValueMax = 40
+
Const ProgressValueMin = 0
      Const ProgressStep = 4
+
Const ProgressValueMax = 40
      REM set minimum and maximum progress value
+
Const ProgressStep = 4
      oProgressBarModel =  
+
REM set minimum and maximum progress value
          oDialog.Model.ProgressBar1oProgressBarModel.ProgressValueMin
+
oProgressBarModel = oDialog.getModel().getByName( "ProgressBar1" )
              ProgressValueMin
+
oProgressBarModel.setPropertyValue( "ProgressValueMin", ProgressValueMin)
      oProgressBarModel.ProgressValueMax = ProgressValueMax
+
oProgressBarModel.setPropertyValue( "ProgressValueMax", ProgressValueMax)
      REM disable cancel and start button
+
REM show progress bar
      oCancelButtonModel = oDialog.Model.CommandButton1
+
oDialog.setVisible( True )
      oCancelButtonModel.Enabled = False
+
REM increase progress value every second
      oStartButtonModel = oDialog.Model.CommandButton2
+
For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
      oStartButtonModel.Enabled = False
+
oProgressBarModel.setPropertyValue( "ProgressValue", ProgressValue )
      REM show progress bar
+
Wait 1000
      oProgressBar = oDialog.getControl("ProgressBar1")
+
Next ProgressValue
      oProgressBar.setVisible( True )
+
End Sub
      REM increase progress value every second
+
</syntaxhighlight>
      For ProgressValue =  
+
              ProgressValueMin To ProgressValueMax Step ProgressStep
+
          oProgressBarModel.ProgressValue = ProgressValue
+
          Wait 1000
+
      Next ProgressValue
+
      REM hide progress bar
+
      oProgressBar.setVisible( False )
+
      REM enable cancel and start button
+
      oCancelButtonModel.Enabled = True
+
      oStartButtonModel.Enabled = True
+
  End Sub
+
</source>
+
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]

Latest revision as of 12:47, 21 December 2020



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