Domino Code Fragment

Code Name*
Progress Bar class
Date*
03/26/2001
Source (or email address if you prefer)*
Ian Sherwood
IP address:.205.136.152.225
Description*
Class file implementation of the code to control a Progress Bar.
Type*
LotusScript
Categories*
User Interface (Notes)
Implementation:
Modify constants
Required Client:
4.5
Server:
(none)
Limitations:
Comments:
See the .zip file for documentation
Files/Graphics attachments (if applicable): Code:
'///////////////////////////////////////////////////////////////////
' PROGRESS.LSS //
'/////////////////////////////////////////////////////////////////
'History
'98/09/01 irs created based on code from Mark Dixon at
' Ives Development.
'
'Usage: place this file in the program directory (or in a subdir
'like \program\lss). Place the following line in the (Declarations)
'event of your code. Besure to use the correct path
'
'%INCLUDE "lss\progress.lss"
'
'
'This file includes all of the declarations required to create a
'graphical progress bar from LotusScript. Most of this comes from
'sample code from Mark Dixon @ Ives Development (posted on a public
'web site with no copyright information).


'////////////////////////////////////////////////////////////////////
' Constants //
'//////////////////////////////////////////////////////////////////
Const NPB_TWOLINE% = 1
Const NPB_STATUSBAR% = 32

'////////////////////////////////////////////////////////////////////
' Functions & Subs //
'//////////////////////////////////////////////////////////////////
' function prototypes for Notes 32-bit
Declare Function NEMProgressBegin Lib "nnotesws.dll" ( Byval wFlags As Integer ) As Long
Declare Sub NEMProgressDeltaPos Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwIncrement As Long )
Declare Sub NEMProgressEnd Lib "nnotesws.dll" ( Byval hwnd As Long )
Declare Sub NEMProgressSetBarPos Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwPos As Long)
Declare Sub NEMProgressSetBarRange Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwMax As Long )
Declare Sub NEMProgressSetText Lib "nnotesws.dll" ( Byval hwnd As Long, Byval pcszLine1 As String, Byval pcszLine2 As String )



'////////////////////////////////////////////////////////////////////
' Class: ProgressBar //
'//////////////////////////////////////////////////////////////////
Class ProgressBar

'////////////////////////////////////////////////////////////////////
' Constants & Variables //
'//////////////////////////////////////////////////////////////////
Private hwnd As Long
Private lng_Rng as Long
Private lng_CurrentPosition as Long

'////////////////////////////////////////////////////////////////////
' New //
'//////////////////////////////////////////////////////////////////

Sub New( s_Title as string, s_Caption as string, lng_Range as Long )
'Check for a valid range, then save it
if lng_Range < 1 then
exit sub
Else
lng_Rng = lng_Range

'Create the progress bar
hwnd = NEMProgressBegin( NPB_TWOLINE )

'Set the bar range
NEMProgressSetBarRange hwnd, lng_Rng

'Display some text on the dialog. The second line is ignored if NPB_TWOLINE not specified
NemProgressSetText hwnd, s_Title, s_Caption

lng_CurrentPosition = 0
End If

End Sub 'New


'////////////////////////////////////////////////////////////////////
' UpdatePosition //
'//////////////////////////////////////////////////////////////////
Sub UpdatePosition( lng_Update as Long )
'Check that update value is within valid range
If lng_Update < 0 Or Lng_Update > lng_Rng then
'Update is outside range, so do not update!!!
Exit Sub
Else
'Update the bar position -
NEMProgressSetBarPos hwnd, lng_Update
lng_CurrentPosition = lng_Update
End If

End Sub 'UpdatePosition

'////////////////////////////////////////////////////////////////////
' IncrementPosition //
'//////////////////////////////////////////////////////////////////
Sub IncrementPosition( )
'Increments by 1 only. Will not increment if current position
'is already equal to maximum range
if lng_CurrentPosition < lng_Rng then
NEMProgressDeltaPos hwnd, 1
lng_CurrentPosition = lng_CurrentPosition + 1
end if
End Sub 'IncrementPosition


'////////////////////////////////////////////////////////////////////
' UpdateTitles //
'//////////////////////////////////////////////////////////////////
Sub UpdateTitles( s_Title as string, s_Caption as string )
NEMProgressSetText hwnd, s_Title, s_Caption

End Sub 'Update


'////////////////////////////////////////////////////////////////////
' Delete //
'//////////////////////////////////////////////////////////////////
Sub Delete
'Destroy the dialog when we're done
NEMProgressEnd hwnd

'Print "ProgressBar destroying object"

End Sub 'Delete

End Class 'ProgressBar
File Attachment Icon
ProgressBar.zip