• Enhancement for Progressbar (Switch it off if in debug mode)

    By Norbert Goeth 1 decade ago

    Dear David,



    I extended the Script-Library PROGRESSBAR by a little Function which determines if you are running in Debug-Mode. If you do so - the Progressbar is switched off. Perhaps something for 1.3.

    Code below:



    '—————— Progress Bar in the C Windows API ——————

    Declare Public Function NEMProgressBegin Lib "nnotesws.dll" ( Byval wFlags As Integer ) As Long

    Declare Public Sub NEMProgressDeltaPos Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwIncrement As Long )

    Declare Public Sub NEMProgressEnd Lib "nnotesws.dll" ( Byval hwnd As Long )

    Declare Public Sub NEMProgressSetBarPos Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwPos As Long)

    Declare Public Sub NEMProgressSetBarRange Lib "nnotesws.dll" ( Byval hwnd As Long, Byval dwMax As Long )

    Declare Public Sub NEMProgressSetText Lib "nnotesws.dll" ( Byval hwnd As Long, Byval pcszLine1 As String, Byval pcszLine2 As String )



    Const NPB_TWOLINE = 3

    Const NPB_ONELINE = 2



    Public Class LNProgressbar

    <br/>
    hwnd As Long<br/>
    DebugMode As Integer<br/>
    <br/>
    Sub New(SecondLineVisible As Integer)<br/>
       'Set-up the progress bar on the screen<br/>
        DebugMode=IsDebugMode<br/>
        If Not DebugMode Then<br/>
            If SecondLineVisible Then<br/>
                hwnd = NEMProgressBegin(NPB_TWOLINE) <br/>
            Else<br/>
                hwnd = NEMProgressBegin(NPB_ONELINE)<br/>
            End If<br/>
        End If<br/>
    End Sub<br/>
    <br/>
    Sub SetText(FirstLineText As String,SecondLineText As String)<br/>
        If Not DebugMode Then<br/>
           'Display the text in progress bar <br/>
            NemProgressSetText hwnd, FirstLineTExt,SecondLineText <br/>
        End If<br/>
    End Sub<br/>
    <br/>
    Sub SetProgressPos(Progresspos As Long)<br/>
        If Not DebugMode Then<br/>
            NEMProgressSetBarPos hwnd, ProgressPos <br/>
        End If<br/>
    End Sub<br/>
    <br/>
    Sub SetProgressRange(ProgressMaxElements As Long)<br/>
    

    'Set-up the max elements in the progress bar, if you have

    'a list with 230 elements then set the MAX to 230 elements.

    'For every element you proceed increase the SetProgressPos

    'by one to reached 230

        <br/>
        If Not DebugMode Then<br/>
            NEMProgressSetBarRange hwnd, ProgressMaxElements<br/>
        End If<br/>
    End Sub<br/>
    <br/>
    Sub DeltaPos(DPos As Long)<br/>
    

    ' This function adds the number in DPOS to the current ProgressPos

        If Not DebugMode Then<br/>
            NEMProgressDeltaPos hwnd, DPos<br/>
        End If<br/>
    End Sub <br/>
    <br/>
    Sub Delete<br/>
    

    'Terminate the progress bar on the screen

        If Not DebugMode Then<br/>
            NEMProgressEnd hwnd<br/>
        End If<br/>
    End Sub<br/>
    <br/>
    Public Function IsDebugMode() As Integer<br/>
        Dim start As Variant<br/>
        start = Getthreadinfo(6) ' LSI_THREAD_TICKS<br/>
        Stop<br/>
        If Getthreadinfo(6) - start &gt; 100 Then IsDebugMode = True<br/>
        ' If you debug the application you will not be able to press the CONTINUE-Buton <br/>
        ' within less then 100 milliseconds, otherwise the STOP-statement is not in function<br/>
        ' and you will always be quicker then 100 milliseconds<br/>
    End Function<br/>
    

    End Class

    • Thank you - yes another good one for 1.3

      By David Jeyachandran 1 decade ago

      That's another good suggestion that I'll implement in 1.3. Sounds easier than what I do with changing a constant.



      Thank you!



      Regards

      David